Skip to content

Commit

Permalink
fix(errors): use title if present (#449)
Browse files Browse the repository at this point in the history
  • Loading branch information
Integralist authored Jun 23, 2023
1 parent 23b1f87 commit ea1a7c3
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion fastly/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ type ErrorObject struct {
type legacyError struct {
Detail string `mapstructure:"detail"`
Message string `mapstructure:"msg"`
Title string `mapstructure:"title"`
}

// NewHTTPError creates a new HTTP error from the given code.
Expand Down Expand Up @@ -412,8 +413,12 @@ func NewHTTPError(resp *http.Response) *HTTPError {
if err := decodeBodyMap(body, &lerr); err != nil {
addDecodeErr()
} else if lerr != nil {
msg := lerr.Message
if msg == "" && lerr.Title != "" {
msg = lerr.Title
}
e.Errors = append(e.Errors, &ErrorObject{
Title: lerr.Message,
Title: msg,
Detail: lerr.Detail,
})
}
Expand Down

0 comments on commit ea1a7c3

Please sign in to comment.