/** * Return the detail message, including the message from the nested exception * if there is one. */ @Override @Nullable public String getMessage() { return NestedExceptionUtils.buildMessage(super.getMessage(), getCause()); }
/** * Return the detail message, including the message from the nested exception * if there is one. */ @Override @Nullable public String getMessage() { return NestedExceptionUtils.buildMessage(super.getMessage(), getCause()); }
@Test public void testNestedServletExceptionStringThrowable() { Throwable cause = new RuntimeException(); NestedServletException exception = new NestedServletException("foo", cause); assertEquals(NestedExceptionUtils.buildMessage("foo", cause), exception.getMessage()); assertEquals(cause, exception.getCause()); }
private void filterAndRecordMetrics(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws IOException, ServletException { TimingContext timingContext = TimingContext.get(request); if (timingContext == null) { timingContext = startAndAttachTimingContext(request); } try { filterChain.doFilter(request, response); if (!request.isAsyncStarted()) { // Only record when async processing has finished or never been started. // If async was started by something further down the chain we wait // until the second filter invocation (but we'll be using the // TimingContext that was attached to the first) Throwable exception = (Throwable) request .getAttribute(DispatcherServlet.EXCEPTION_ATTRIBUTE); record(timingContext, response, request, exception); } } catch (NestedServletException ex) { response.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value()); record(timingContext, response, request, ex.getCause()); throw ex; } }
@ExceptionHandler(NestedServletException.class) public ResponseEntity<String> HandleNested(NestedServletException ex) { Throwable cause = ex.getCause(); if (cause instanceof InternalError) { // deal with it } else if (cause instanceof OtherError) { // deal in some other way } }
@ExceptionHandler(org.springframework.web.util.NestedServletException.class) public void test(NestedServletException e) { Throwable t = e.getCause(); logger.debug("*************************** "+t.getClass().getName()); }
@ExceptionHandler(org.springframework.web.util.NestedServletException.class) public void test(NestedServletException e) { Throwable t = e.getCause(); logger.debug("*************************** "+t.getClass().getName()); }
/** * Return the detail message, including the message from the nested exception * if there is one. */ @Override @Nullable public String getMessage() { return NestedExceptionUtils.buildMessage(super.getMessage(), getCause()); }
/** * Return the detail message, including the message from the nested exception * if there is one. */ @Override @Nullable public String getMessage() { return NestedExceptionUtils.buildMessage(super.getMessage(), getCause()); }
/** * Return the detail message, including the message from the nested exception * if there is one. */ public String getMessage() { if (getCause() == null) { return super.getMessage(); } else { return super.getMessage() + "; nested exception is " + getRootCause().getClass().getName() + ": " + getRootCause().getMessage(); } }
record(timingContext, response, request, handlerObject, e.getCause()); throw e;