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
ban Throwable.toString() and Throwable.getMessage() #10021
Conversation
+1 |
+1 On Fri, Mar 6, 2015 at 12:33 PM, Luca Cavanna notifications@github.com
|
Very nice :) +1 |
+1 FWIW, the main place I see exceptions being simplified is in |
lets fix them +1 rob, we can also open a public branch for this... |
@rmuir do you wanna open a public branch and we fix it there? |
I spent some time the past few days looking at where we actually use .getMessage() in the code:
Caveat: I was starting to make changes in a local bug fix branch a bit too quickly resulting in a) a pretty large diff with changes related to all of the above mixed together, b) breaking two unit tests as a result. Trying to concentrate on the first bullet point for a cleaner approach first. |
Adds *Exception(Throwable cause) constructors and calls them where appropriate thus getting rid of 16 instances of calling getMessage and eliminating the risk of loosing exception context. Fixes ElasticsearchTimeoutException along the way (used to discard the parameter args in the (String message, Object... args) constructor, passes it up to super now. Relates to elastic#10021
Also forwards exception objects through failure listeners eliminates another 17 calls to getMessage(). Relates to elastic#10021
Closing this for now, someone can base work off of it if desired in the future. |
This way, we never have "partial exceptions" with incomplete information anywhere.
I havent yet fixed any of the 97 violations in question.
Errors in the branch look like this:
[ERROR] Forbidden method invocation: java.lang.Throwable#getMessage() [Use ExceptionsHelper.stackTrace(Throwable) instead]
[ERROR] in org.elasticsearch.index.snapshots.blobstore.BlobStoreIndexShardRepository (BlobStoreIndexShardRepository.java:152)