Is there a consistent error object? I haven’t been able to find much documentation on Error Handling and what errors I’ve come across use different responses. For example, if you attempt to create a customer and the admin email is a duplicate, the exception is a ValidationError and you can access the response messages as follow:
except dwollav2.ValidationError as e:
return HttpResponse(status=e.status, reason=e.body['_embedded']['errors'][0]['message'])
If a user were to attempt to add a new bank account, and this bank account has already been added, the exception is just a generic ‘Error’, which is fine, but the entire body of the response is different from the previous example.
try:
customer = app_token.post('%s/funding-sources' % customer_url, request_body)
except dwollav2.error.Error as e:
# the captured error response is as follow:
# e.status = 400
# e.body:
{'code' : 'DuplicateResource',
'message': 'Bank already exists: id=...',
'_links': {'about': {'href': '..., 'type': 'application/vnd.dwolla.v1.hal+json', 'resource-type': 'funding-source'}}}
Why are the error object attributes different from error to error?
