Documentation ¶
Index ¶
- func GetCategory(err error) categories.Category
- func GetCode(err error) codes.Code
- func GetOperation(err error) string
- func New(c codes.Code, operation string, msg string) error
- func Newf(c codes.Code, operation string, format string, a ...interface{}) error
- func WithCode(err error, code codes.Code) error
- func WithCodeAndOperation(err error, code codes.Code, operation string) error
- func WithOperation(err error, operation string) error
- type ErrorCoder
- type ErrorOperation
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetCategory ¶
func GetCategory(err error) categories.Category
func GetOperation ¶
func Newf ¶
Example ¶
coErr := Newf(codes.DataSchemaNotFound, "test", "hello %s", "world") coErrWithHint := errors.WithHint(coErr, "sumo hint") // fmt.Printf("%+v", coErrWithHint) fmt.Println(errors.FlattenHints(coErrWithHint)) fmt.Println(GetOperation(coErrWithHint)) fmt.Println(GetCode(coErrWithHint)) fmt.Println(GetCategory(coErrWithHint)) fmt.Println(errors.GetAllHints(coErrWithHint))
Output: sumo hint test DataSchemaNotFound Data [sumo hint]
func WithCode ¶
Wrapper constructors are for wrapping additional traits to previous error WithCode adds code to an existing error.
func WithCodeAndOperation ¶
WithCodeAndOperation adds code and operation to an existing error.
func WithOperation ¶
WithOperation adds operation to an existing error.
Types ¶
type ErrorCoder ¶
type ErrorCoder interface { error Code() codes.Code Category() categories.Category }
ErrorHinter is implemented by types that can provide Machine-readable error code.
type ErrorOperation ¶
ErrorOperation is implemented by types that can provide Logical Operation that caused the failure
Click to show internal directories.
Click to hide internal directories.