forked from openservicemesh/osm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
errcode: introduce error code management
Introduces a pkg to manage error codes. Documentation and tooling to inspect errors will be built around the error code and description mapping provided by this pkg. Part of openservicemesh#2866 Signed-off-by: Shashank Ram <shashr2204@gmail.com>
- Loading branch information
1 parent
94449b5
commit af1751b
Showing
2 changed files
with
34 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Package errcode defines the error codes for error messages and an explanation | ||
// of what the error signifies. | ||
package errcode | ||
|
||
import ( | ||
"fmt" | ||
) | ||
|
||
type errCode int | ||
|
||
const ( | ||
// Kind defines the kind for the error code constants | ||
Kind = "error_code" | ||
) | ||
|
||
// Range 1000-1050 is reserved for errors related to | ||
const ( | ||
// ErrInvalidCLIArgument refers to an invalid CLI argument being specified | ||
ErrInvalidCLIArgument errCode = iota + 1000 | ||
) | ||
|
||
// String returns the error code as a string, ex. E1000 | ||
func (e errCode) String() string { | ||
return fmt.Sprintf("E%d", e) | ||
} | ||
|
||
//nolint: deadcode,varcheck,unused | ||
var errCodeMap = map[errCode]string{ | ||
ErrInvalidCLIArgument: ` | ||
An invalid comment line argument was passed to the application. | ||
`, | ||
} |