- 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

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -