Return structured errors for provider status failures
This commit is contained in:
@@ -1114,6 +1114,15 @@ func checkCommonResponseFailures(t *testing.T) {
|
||||
if !errors.Is(err, tc.wantErr) {
|
||||
t.Fatalf("error = %v, want %v", err, tc.wantErr)
|
||||
}
|
||||
if tc.statusCode < http.StatusOK || tc.statusCode >= http.StatusMultipleChoices {
|
||||
var providerHTTPError *ProviderHTTPError
|
||||
if !errors.As(err, &providerHTTPError) {
|
||||
t.Fatalf("error = %T, want *ProviderHTTPError", err)
|
||||
}
|
||||
if got := providerHTTPError.StatusCode(); got != tc.statusCode {
|
||||
t.Fatalf("provider status = %d, want %d", got, tc.statusCode)
|
||||
}
|
||||
}
|
||||
if tc.wantText != "" && !strings.Contains(err.Error(), tc.wantText) {
|
||||
t.Fatalf("error %q does not contain %q", err, tc.wantText)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user