Skip to content

Commit

Permalink
feat: show errors
Browse files Browse the repository at this point in the history
  • Loading branch information
brokeyourbike committed Jun 19, 2024
1 parent 988112a commit a94951e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion err.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ type ErrResponse struct {
}

func (e ErrResponse) Error() string {
return fmt.Sprintf("Error during API call. status: %d type: %s title: %s", e.Status, e.Type, e.Title)
return fmt.Sprintf("Error during API call. Status: %d Type: %s Title: %s Errors: %s", e.Status, e.Type, e.Title, e.Errors)
}
2 changes: 2 additions & 0 deletions err_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func TestErrResponse_Errors(t *testing.T) {
assert.Len(t, resp.Errors, 2)
assert.Equal(t, resp.Errors["DebitAccountIban"][0], "Debit Account IBAN must be populated and should be in a valid IBAN format")
assert.Equal(t, resp.Errors["CreditAccountIban"][0], "Credit Account IBAN must be populated and should be in a valid IBAN format")
assert.Equal(t, "Error during API call. Status: 400 Type: https://tools.ietf.org/html/rfc7231#section-6.5.1 Title: One or more validation errors occurred. Errors: map[CreditAccountIban:[Credit Account IBAN must be populated and should be in a valid IBAN format] DebitAccountIban:[Debit Account IBAN must be populated and should be in a valid IBAN format]]", resp.Error())
}

func TestErrResponse_NoErrors(t *testing.T) {
Expand All @@ -41,4 +42,5 @@ func TestErrResponse_NoErrors(t *testing.T) {
assert.NoError(t, err)

assert.Len(t, resp.Errors, 0)
assert.Equal(t, "Error during API call. Status: 400 Type: https://tools.ietf.org/html/rfc7231#section-6.5.1 Title: One or more validation errors occurred. Errors: map[]", resp.Error())
}

0 comments on commit a94951e

Please sign in to comment.