-
Notifications
You must be signed in to change notification settings - Fork 76
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
fixes broken exception handling on http status code != ok. #43
base: master
Are you sure you want to change the base?
Conversation
a new exception ApiHttpError for status code handling.
Thanks for catching this issue. I'm not sure exactly which error brought this up, but a related fix in 8e69958 may solve the issue. Could you check whether you still run into the same problem on master? |
#8e69958 solves the syntax error but does not handle http errors any better than before. some issues i see with the current handling of http error:
why i added a new class:
I see several options to improve the error handling: this pr
integrate http error code handling into api error exception
there will probably be more pros/cons. but thats what just popped up in my head. I'm looking for some input here. If the second option is the preferred way, I'm glad to write another pr for that case. |
So is it the case that all error responses with JSON bodies have a status code of 200? I don't have a strong preference about this. If we expect that users will want to catch 200 and non-200 errors separately, the extra exception class would be nice. On the other hand, if the more common use case is to handle both error categories in the same way, then the second exception type means lots of code like If you have a preference for your current solution, I'm happy to merge. |
yes responses that carry a json (or any payload data) should have response code 200. according to the RFC code 203 is also possible, but I don't think betfair uses it. (I've not seen many company using it actually) see also http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html. Different codes are possible for example 3xx for redirect requests and 401 (unauthorised) but all those responses do not carry a json payload. the main reason why I actually prefer two exception classes is, that in case of, for example error code 503 (Service Unavailable), I'd like to retry till the request is not of interest anymore for me or the server continues to respond. But in case of an API error, for example "market not found", I don't need to retry, the market will not come back just because I try more often ;) |
I've created pr #51 with a proposal of handling this case. |
the current handling of http error codes != ok is broken, so i fixed this with a new class explicit for this cases. the exception message contains the http status code, so does the exception object has an attribute for status_code.