Fri, 22 May 2020 17:19:09 +0200
improves error message for InvocationTargetExceptions
src/main/java/de/uapcore/lightpit/AbstractLightPITServlet.java | file | annotate | diff | comparison | revisions |
--- a/src/main/java/de/uapcore/lightpit/AbstractLightPITServlet.java Fri May 22 16:21:59 2020 +0200 +++ b/src/main/java/de/uapcore/lightpit/AbstractLightPITServlet.java Fri May 22 17:19:09 2020 +0200 @@ -40,6 +40,7 @@ import javax.servlet.http.HttpSession; import java.io.IOException; import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.sql.Connection; @@ -132,10 +133,17 @@ } } return (ResponseType) method.invoke(this, paramValues); + } catch (InvocationTargetException ex) { + LOG.error("invocation of method {}::{} failed: {}", + method.getDeclaringClass().getName(), method.getName(), ex.getTargetException().getMessage()); + LOG.debug("Details: ", ex.getTargetException()); + resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, ex.getTargetException().getMessage()); + return ResponseType.NONE; } catch (ReflectiveOperationException | ClassCastException ex) { - LOG.error("invocation of method {} failed: {}", method.getName(), ex.getMessage()); + LOG.error("invocation of method {}::{} failed: {}", + method.getDeclaringClass().getName(), method.getName(), ex.getMessage()); LOG.debug("Details: ", ex); - resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, ex.getMessage()); return ResponseType.NONE; } }