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 |
1.1 --- a/src/main/java/de/uapcore/lightpit/AbstractLightPITServlet.java Fri May 22 16:21:59 2020 +0200 1.2 +++ b/src/main/java/de/uapcore/lightpit/AbstractLightPITServlet.java Fri May 22 17:19:09 2020 +0200 1.3 @@ -40,6 +40,7 @@ 1.4 import javax.servlet.http.HttpSession; 1.5 import java.io.IOException; 1.6 import java.lang.reflect.Constructor; 1.7 +import java.lang.reflect.InvocationTargetException; 1.8 import java.lang.reflect.Method; 1.9 import java.lang.reflect.Modifier; 1.10 import java.sql.Connection; 1.11 @@ -132,10 +133,17 @@ 1.12 } 1.13 } 1.14 return (ResponseType) method.invoke(this, paramValues); 1.15 + } catch (InvocationTargetException ex) { 1.16 + LOG.error("invocation of method {}::{} failed: {}", 1.17 + method.getDeclaringClass().getName(), method.getName(), ex.getTargetException().getMessage()); 1.18 + LOG.debug("Details: ", ex.getTargetException()); 1.19 + resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, ex.getTargetException().getMessage()); 1.20 + return ResponseType.NONE; 1.21 } catch (ReflectiveOperationException | ClassCastException ex) { 1.22 - LOG.error("invocation of method {} failed: {}", method.getName(), ex.getMessage()); 1.23 + LOG.error("invocation of method {}::{} failed: {}", 1.24 + method.getDeclaringClass().getName(), method.getName(), ex.getMessage()); 1.25 LOG.debug("Details: ", ex); 1.26 - resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); 1.27 + resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, ex.getMessage()); 1.28 return ResponseType.NONE; 1.29 } 1.30 }