Skip to content

Raise exception for unsuccessful requests #5

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

Conversation

deanmalan
Copy link
Contributor

Hi @elchicodepython, thank you for writing this package!

I've added a response.raise_for_status() call so that exceptions will be raised when the request did not return a 200 response. Otherwise, it's hard to know whether the request was a success or not.

This might be a breaking change for other users though so might I suggest that you bump the package's version to a new major version after this change? E.g. 1.0.0. :)

@elchicodepython
Copy link
Owner

Hello @delenamalan ! Thank for your PR. ❤️

I see the use case but I'm a little bit worry about raising requests specific exceptions as maybe in a future we implement a NocoDBClient using other library (that's the idea of the infra layer). I think that we should add some custom exceptions to be raised by any NocoDBClient. So this way the exceptions raised are from our domain and if we change the infra library or we add a new implementation the handling of this exceptions by the users keep working.

Something like...

exceptions.py

class NocoDBAPIError(Exception):
    ...

infra/requests_client.py

#A 
try:
    response.raise_for_status()
except except requests.exceptions.HTTPError:
    raise NocoDBApiError(url, code=response.status)

I can add it by myself but as I see you quite motivated I can let you to add it in this PR if you want. If not tell me please so I can add it during this weekend that I will have some free time there.

Is it good for you? 😄

@elchicodepython elchicodepython added question Further information is requested and removed in-technical-review labels Feb 28, 2023
@elchicodepython elchicodepython removed their request for review February 28, 2023 20:01
@elchicodepython elchicodepython added this to the 1.0 milestone Mar 3, 2023
@elchicodepython elchicodepython added in-technical-review and removed question Further information is requested labels Mar 3, 2023
@elchicodepython elchicodepython merged commit b948dd6 into elchicodepython:master Mar 3, 2023
@elchicodepython
Copy link
Owner

PR merged and package 1.0.0 published! Congrats @delenamalan 🚀 !!

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

Successfully merging this pull request may close these issues.

2 participants