maintain underlying error structs to allow for type conversion (#293)
* maintain underlying error structs to allow for type conversion and defensive error checking * allow Error.Is for Azure responses * update readme, add tests to ensure type conversion * fix whitespacing * read me * add import to readme example
This commit is contained in:
6
error.go
6
error.go
@@ -25,6 +25,10 @@ type ErrorResponse struct {
|
||||
}
|
||||
|
||||
func (e *APIError) Error() string {
|
||||
if e.HTTPStatusCode > 0 {
|
||||
return fmt.Sprintf("error, status code: %d, message: %s", e.HTTPStatusCode, e.Message)
|
||||
}
|
||||
|
||||
return e.Message
|
||||
}
|
||||
|
||||
@@ -70,7 +74,7 @@ func (e *APIError) UnmarshalJSON(data []byte) (err error) {
|
||||
}
|
||||
|
||||
func (e *RequestError) Error() string {
|
||||
return fmt.Sprintf("status code %d, message: %s", e.HTTPStatusCode, e.Err)
|
||||
return fmt.Sprintf("error, status code: %d, message: %s", e.HTTPStatusCode, e.Err)
|
||||
}
|
||||
|
||||
func (e *RequestError) Unwrap() error {
|
||||
|
||||
Reference in New Issue
Block a user