-
Notifications
You must be signed in to change notification settings - Fork 2
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
Create exception hierarchy based on status code classes #4
Comments
As required by HTTP: > [..] However, a client MUST > understand the class of any status code, as indicated by the first > digit, and treat an unrecognized status code as being equivalent to > the x00 status code of that class, with the exception that a > recipient MUST NOT cache a response with an unrecognized status code. See RFC 7231, section 6. Error status handling will be improved with #4.
With #13 improving error handling in Grac 2, it might make sense to move this to the next major version, so we can properly refactor exceptions. Here are a few further ideas: No separate classes for individual error codesIn a distributed service environment, HTTP error codes are almost never enough. There are especially lot's of different cases on why a response could be a 'bad request', ranging from an invalid request format via invalid attribute values in the correct format, to a server resource being in a state that's incompatible with the request. We pretty much always (except maybe for 404s) check an error code in the response (which gets easier with #13). Thus, we catch the Covering all known HTTP error codes would result in a lot of classes we probably don't need. Also, making this usable for people outside Barzahlen might require a way to support additional HTTP status codes via some kind of extension mechanism that would make exception handling even more complicated or annoying to use. That's probably not worth it. So, instead of creating lots of individual exceptions for status codes, we could create one exception class per HTTP status code class, at least for the error classes Rename
|
I have no objections |
Currently, there is no way to catch all exceptions for a specific class of status codes.
A client might e.g. want to retry requests based on the status code class. It might e.g. make sense to retry a request returning a 5xx server error, but not to retry the request for a 4xx client error (that would fail again anyway with the same parameters).
Such a hierarchy would also allow us to better process status codes that don't have a specific exception for.
Suggestions for a hierarchy:
We'll have to extend this hierarchy when adding more status codes (see #1). We don't explicitly deal with redirects yet, so nothing on 3xx codes here.
Still missing:
The text was updated successfully, but these errors were encountered: