-
Notifications
You must be signed in to change notification settings - Fork 66
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
Exception handling #44
Comments
I would just add that logging is only one of several possible ways to handle errors. And it's not the best solution here, because random network failures create a lot of log noise. I would prefer to be able to count the exceptions instead and raise alarm only if there are too many of them. |
As for the actual API, I recommend throwing an exception in synchronous calls and storing it in the returned Future in asynchronous calls. If that doesn't agree with you, then the next best option is to supply exception handler in config. Default handler would implement the old behavior. People could just rethrow in the handler if they prefer the exception to be propagated. |
Added this api. Any feedback welcome. fb392c2 |
Looks good. Could be simpler if you just propagated the exception. |
The code reminds me of my own library NoException, which provides many different kinds of exception handlers. It is nevertheless trivial to adapt NoException handlers to the |
NoException seems like a nice library but I would be hesitant to add another dependency. But hope functional interface would make it easy to adopt. |
google-analytics-java/src/main/java/com/brsanthu/googleanalytics/httpclient/ApacheHttpClientImpl.java
Lines 100 to 112 in 8ad1c1d
There is no way of knowing what happened if a
post()
fails. I think you should throw the error and let the caller deal with it. Other option is to set theException
in a new field on theHttpResponse
(which will always be empty in case of a failure).Check:
The text was updated successfully, but these errors were encountered: