Skip to content

Commit 62fd26d

Browse files
authored
Merge pull request #979 from jackchenjc/issue-978
feat: Add Kind() method to EdgeX error interface
2 parents a8c5c64 + 9172608 commit 62fd26d

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

errors/types.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// Copyright (C) 2020-2021 IOTech Ltd
2+
// Copyright (C) 2020-2025 IOTech Ltd
33
//
44
// SPDX-License-Identifier: Apache-2.0
55

@@ -51,6 +51,8 @@ type EdgeX interface {
5151
Message() string
5252
// Code returns the status code of this error.
5353
Code() int
54+
// Kind returns the error kind of this error.
55+
Kind() string
5456
}
5557

5658
// CommonEdgeX generalizes an error structure which can be used for any type of EdgeX error.
@@ -130,6 +132,11 @@ func (ce CommonEdgeX) Code() int {
130132
return ce.code
131133
}
132134

135+
// Kind returns the error kind of this error.
136+
func (ce CommonEdgeX) Kind() string {
137+
return string(ce.kind)
138+
}
139+
133140
// Unwrap retrieves the next nested error in the wrapped error chain.
134141
// This is used by the new wrapping and unwrapping features available in Go 1.13 and aids in traversing the error chain
135142
// of wrapped errors.

0 commit comments

Comments
 (0)