mirror of
https://github.com/crunchy-labs/crunchy-cli.git
synced 2026-01-21 12:12:00 -06:00
Fix error handling caused panic
This commit is contained in:
parent
c86595d2c6
commit
475dc34f7a
1 changed files with 5 additions and 1 deletions
|
|
@ -331,7 +331,11 @@ func request(req *http.Request, client *http.Client) (*http.Response, error) {
|
||||||
} else if _, ok := errMap["code"]; ok {
|
} else if _, ok := errMap["code"]; ok {
|
||||||
if errContext, ok := errMap["context"]; ok {
|
if errContext, ok := errMap["context"]; ok {
|
||||||
errField := errContext.([]any)[0].(map[string]any)
|
errField := errContext.([]any)[0].(map[string]any)
|
||||||
return nil, &RequestError{Response: resp, Message: fmt.Sprintf("%s - %s", errField["code"].(string), errField["field"].(string))}
|
var code string
|
||||||
|
if code, ok = errField["message"].(string); !ok {
|
||||||
|
code = errField["code"].(string)
|
||||||
|
}
|
||||||
|
return nil, &RequestError{Response: resp, Message: fmt.Sprintf("%s - %s", code, errField["field"].(string))}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue