MCPcopy
hub / github.com/benbjohnson/wtf / ErrorMessage

Function ErrorMessage

error.go:56–64  ·  view source on GitHub ↗

ErrorMessage unwraps an application error and returns its message. Non-application errors always return "Internal error".

(err error)

Source from the content-addressed store, hash-verified

54// ErrorMessage unwraps an application error and returns its message.
55// Non-application errors always return "Internal error".
56func ErrorMessage(err error) string {
57 var e *Error
58 if err == nil {
59 return ""
60 } else if errors.As(err, &e) {
61 return e.Message
62 }
63 return "Internal error."
64}
65
66// Errorf is a helper function to return an Error with a given code and formatted message.
67func Errorf(code string, format string, args ...interface{}) *Error {

Calls

no outgoing calls