- Where Developers Learn, Share, & Build Careers
I use method.invoke to call a method that throws a custom exception. What are the methods of catching this exception and handle it in an attempt to catch around Try.invoke? The only way I can think is to catch all the exceptions and test the exception type;
try {... method.invoke ...} hold (AE) {}
Try:
try {method.invoke} (invocation targeting x) {throwable main exception = e.getCause (); If (mainException instanceof .....) {}} InvocationTargetException is the cover for the exception thrown by the method.
In your case, the main exception would be A .
Comments
Post a Comment