java.lang.reflect
Class InvocationTargetException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by java.lang.reflect.InvocationTargetException
All Implemented Interfaces:
Serializable

public class InvocationTargetException
extends Exception

InvocationTargetException is sort of a way to "wrap" whatever exception comes up when a method or constructor is called via Reflection. As of JDK 1.4, it was retrofitted to match the exception chaining of all other exceptions, but getTargetException() still works.

Since:
1.1
See Also:
Method.invoke(Object,Object[]), Constructor.newInstance(Object[]), Serialized Form

Constructor Summary
protected InvocationTargetException()
          Construct an exception with null as the cause.
  InvocationTargetException(Throwable targetException)
          Create an InvocationTargetException using another exception.
  InvocationTargetException(Throwable targetException, String err)
          Create an InvocationTargetException using another exception and an error message.
 
Method Summary
 Throwable getCause()
          Returns the cause of this exception (which may be null).
 Throwable getTargetException()
          Get the wrapped (targeted) exception.
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

InvocationTargetException

protected InvocationTargetException()
Construct an exception with null as the cause. The cause is initialized to null.


InvocationTargetException

public InvocationTargetException(Throwable targetException)
Create an InvocationTargetException using another exception.

Parameters:
targetException - the exception to wrap

InvocationTargetException

public InvocationTargetException(Throwable targetException,
                                 String err)
Create an InvocationTargetException using another exception and an error message.

Parameters:
targetException - the exception to wrap
err - an extra reason for the exception-throwing
Method Detail

getTargetException

public Throwable getTargetException()
Get the wrapped (targeted) exception.

Returns:
the targeted exception
See Also:
getCause()

getCause

public Throwable getCause()
Returns the cause of this exception (which may be null).

Overrides:
getCause in class Throwable
Returns:
the cause
Since:
1.4