-
Notifications
You must be signed in to change notification settings - Fork 0
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
[jOpenCage] Introduce dedicated exceptions for various potential errors #32
Comments
An Idea from https://stackoverflow.com/a/47058425/1910637 Quick answerIn Spring you have exactly what you want: HttpClientErrorException - Exception thrown when an HTTP 4xx is received. And a recommended practiceMinimally, you should differentiate exceptions related to business logic (e.g., insufficient balance, email address is not valid) from other exceptions (e.g., server not available, unsupported media type, SQLException). In our REST API, we have a library for Java clients that parses responses and throws only three different exceptions: 400, 401, 403, 404, 409, 422: throw MyBusinessException, which contains a message that can be shown to the end user. The message comes in the response body (exception handling on the service side), but if not present we have a default message specific to each status code. |
Each HTTP Error code would have its own Exception, they all extend a base exception.
|
Following a discussion with @lpellegr, the exception names won't always reflect the transport used.
The base exception is going to be JOpenCageException. PR #33 is merged into the NB: Keeping this issue open up to the v3 release |
The package logs the error and returns null. Structuring the exceptions to distinguish between client-side and server-side errors from OpenCage API would help to react to HTTP errors.
Error code can be found at https://opencagedata.com/api#codes
The text was updated successfully, but these errors were encountered: