- 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

java - NullPointerException for a 2d Array -

python - Assemble mpeg file unable to play in mediaplayer -

c# - NameSpace Manager or XsltContent to parse aspx page -