Skip to content

Tag: exception-handling

Handling an exception as a method argument

I am looking for a design pattern to handle Exception instances received as method arguments. To put some context into the question, I am using GWT and have various asynchronous handlers that usually come in a form similar to: So, the onFailure method receives a Throwable instance that I need to handle. Now, I have a number of exceptions I

Best way to check whether a certain exception type was the cause (of a cause, etc …) in a nested exception?

I am writing some JUnit tests that verify that an exception of type MyCustomException is thrown. However, this exception is wrapped in other exceptions a number of times, e.g. in an InvocationTargetException, which in turn is wrapped in a RuntimeException. What’s the best way to determine whether MyCustomException somehow caused the exception that I actually catch? I would like to