Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func String ¶
String will generate an error string that conforms to our error coding style. This will:
- Print the name of the error struct
- Enclose any key sorted values within parenthesis
- Append any wrapped errors to the end of the message (separated by a ":")
Example ¶
package main import ( "fmt" "github.com/xmidt-org/ears/pkg/errs" ) type MyError struct { Message string Code int Err error } func (e *MyError) Error() string { return errs.String( "MyError", map[string]interface{}{ "msg": e.Message, "code": e.Code, }, e.Err, ) } func main() { e := &MyError{ Message: "couldn't compute the meaning of life", Code: -42, Err: fmt.Errorf("observation collapsed the function too hard"), } fmt.Println(e) }
Output: MyError (code=-42 msg=couldn't compute the meaning of life): observation collapsed the function too hard
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.