ErrorMessage unwraps an application error and returns its message. Non-application errors always return "Internal error".
(err error)
| 54 | // ErrorMessage unwraps an application error and returns its message. |
| 55 | // Non-application errors always return "Internal error". |
| 56 | func 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. |
| 67 | func Errorf(code string, format string, args ...interface{}) *Error { |
no outgoing calls