Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client should raise exceptions for errors #46

Open
anentropic opened this issue Jun 15, 2022 · 0 comments
Open

Client should raise exceptions for errors #46

anentropic opened this issue Jun 15, 2022 · 0 comments

Comments

@anentropic
Copy link

except requests.HTTPError as e:

Current design makes it difficult to distinguish error responses from success responses

Either way the client just returns a dictionary

So we have to sniff the fields to see if it "looks like" an error or a success response

But there are problems with that, e.g. https://docs.voucherify.io/reference/errors error body contains a code field, but Get Voucher success response also contains a code field https://docs.voucherify.io/reference/the-voucher-object

error response also has message and details but I wouldn't be surprised if there are success responses that contain those too

A better design would be for the client to raise an exception if error response is received. The exception instance can still have the parsed json error body attached. That way users of the client could trivially distinguish error from success.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant