Skip to content

Commit

Permalink
🥅 Catch and return an error when the API returns a response that coul…
Browse files Browse the repository at this point in the history
…d not be parsed
  • Loading branch information
flovouin committed Sep 22, 2024
1 parent 074c340 commit 8fb12d2
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions internal/provider/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,15 @@ func checkMetabaseResponse(r metabase.MetabaseResponse, err error, statusCodes [
}
}

if r.HasExpectedStatusWithoutExpectedBody() {
return diag.Diagnostics{
diag.NewErrorDiagnostic(
fmt.Sprintf("Unexpected response while calling the Metabase API for operation '%s'.", operation),
fmt.Sprintf("Status code: %d, failed to parse body: %s", r.StatusCode(), r.BodyString()),
),
}
}

for _, s := range statusCodes {
if r.StatusCode() == s {
return diag.Diagnostics{}
Expand Down

0 comments on commit 8fb12d2

Please sign in to comment.