DecodeError binds a json error to the "destPtr".
(err error, destPtr interface{})
| 63 | |
| 64 | // DecodeError binds a json error to the "destPtr". |
| 65 | func DecodeError(err error, destPtr interface{}) error { |
| 66 | apiErr, ok := GetError(err) |
| 67 | if !ok { |
| 68 | return err |
| 69 | } |
| 70 | |
| 71 | return json.Unmarshal(apiErr.Body, destPtr) |
| 72 | } |
| 73 | |
| 74 | // GetErrorCode reads an error, which should be a type of APIError, |
| 75 | // and returns its status code. |