{
Throwable cause = pae.getCause();
if (cause instanceof IllegalArgumentException)
{
// should not be thrown
throw new InternalException(cause);
}
else if (cause instanceof IllegalAccessException)
{
// should not be thrown
throw new InternalException(cause);
}
else if (cause instanceof InvocationTargetException)
{
if (LOG.isDebugEnabled())
{
LOG.debug(cause.getLocalizedMessage(), cause);
}
// get cause of exception that method produces
Throwable throwable = cause.getCause();
// if WebApplicationException than it may contain response
if (WebApplicationException.class == throwable.getClass())
{
throw (WebApplicationException)throwable;
}
throw new InternalException(throwable);
}
else if (cause instanceof RuntimeException)
{
throw (RuntimeException)cause;
}