gocardless-pro-python
gocardless-pro-python copied to clipboard
Add specific type Errors
The API documentation has a ton of errors listed, would it be possible to have these exact errors/exceptions be raised by the library? Currently we have to check for the errors inside of the Error's error (that sentence is a bit ridiculous, but it makes it clear).
We end up with the following constantly:
try:
instance.from_api(
instance.api.create,
params=given
)
except GoCardlessProError as e:
raise DjangoGoCardlessException.from_gocardless_exception(e)
instance.save(*args, **kwargs)
The DjangoGoCardlessException.from_gocardless_exception(e)
would raise the exception that should've been raised by the library.
Instead of that something like this:
try:
instance.from_api(
instance.api.create,
params=given
)
except AccessTokenNotFound as e:
# Perhaps not catch it here, but elsewhere.