ErrorCode unwraps an application error and returns its code. Non-application errors always return EINTERNAL.
(err error)
| 83 | // ErrorCode unwraps an application error and returns its code. |
| 84 | // Non-application errors always return EINTERNAL. |
| 85 | func ErrorCode(err error) Code { |
| 86 | var e *Error |
| 87 | if err == nil { |
| 88 | return Ok |
| 89 | } else if errors.As(err, &e) { |
| 90 | return e.Code |
| 91 | } |
| 92 | return Internal |
| 93 | } |
| 94 | |
| 95 | // Wrapf is a helper function to wrap an Error with given code and formatted message. |
| 96 | func Wrapf(err error, code Code, format string, args ...any) *Error { |
no outgoing calls
no test coverage detected