(err error)
| 6 | ) |
| 7 | |
| 8 | func Extract(err error) (int, string) { |
| 9 | httpErr, ok := err.(*Error) |
| 10 | if !ok { |
| 11 | return http.StatusInternalServerError, http.StatusText(http.StatusInternalServerError) |
| 12 | } |
| 13 | |
| 14 | msg := httpErr.msg |
| 15 | if msg == "" { |
| 16 | msg = http.StatusText(httpErr.statusCode) |
| 17 | } |
| 18 | |
| 19 | return httpErr.statusCode, msg |
| 20 | } |
| 21 | |
| 22 | type Error struct { |
| 23 | err error |