ErrorCode unwraps an application error and returns its code. Non-application errors always return EINTERNAL.
(err error)
| 42 | // ErrorCode unwraps an application error and returns its code. |
| 43 | // Non-application errors always return EINTERNAL. |
| 44 | func ErrorCode(err error) string { |
| 45 | var e *Error |
| 46 | if err == nil { |
| 47 | return "" |
| 48 | } else if errors.As(err, &e) { |
| 49 | return e.Code |
| 50 | } |
| 51 | return EINTERNAL |
| 52 | } |
| 53 | |
| 54 | // ErrorMessage unwraps an application error and returns its message. |
| 55 | // Non-application errors always return "Internal error". |
no outgoing calls