{
args = injectableArguments(request, httpResponse);
}
catch (Exception e)
{
throw new InternalServerErrorException("Failed processing arguments of " + constructor.toString(), e);
}
try
{
return constructor.newInstance(args);
}
catch (InstantiationException e)
{
throw new InternalServerErrorException("Failed to construct " + constructor.toString(), e);
}
catch (IllegalAccessException e)
{
throw new InternalServerErrorException("Failed to construct " + constructor.toString(), e);
}
catch (InvocationTargetException e)
{
Throwable cause = e.getCause();
if (cause instanceof WebApplicationException)
{
throw (WebApplicationException) cause;
}
throw new ApplicationException("Failed to construct " + constructor.toString(), e.getCause());
}
catch (IllegalArgumentException e)
{
String msg = "Bad arguments passed to " + constructor.toString() + " (";
boolean first = false;
for (Object arg : args)
{
if (!first)
{
first = true;
}
else
{
msg += ",";
}
if (arg == null)
{
msg += " null";
continue;
}
msg += " " + arg;
}
throw new InternalServerErrorException(msg, e);
}
}