@Test public void testBuildOfGenericException() { List<ErrorResponses.StackTraceRepresentation> mappedError; try { throw new IOException("simulated I/O error"); } catch (IOException e) { mappedError = ErrorResponses.buildExceptionContext(e); } assertThat(mappedError, is(hasSize(1))); }
static List<StackTraceRepresentation> buildExceptionContext(Throwable cause) { List<StackTraceRepresentation> stackTraces = new ArrayList<>(); for (Throwable currentCause = cause; currentCause != null; currentCause = currentCause.getCause()) { stackTraces.add(new StackTraceRepresentation(currentCause)); } return stackTraces; }
ErrorResponses { static List<StackTraceRepresentation> buildExceptionContext(Throwable cause) { List<StackTraceRepresentation> stackTraces = new ArrayList<>(); for (Throwable currentCause = cause; currentCause != null; currentCause = currentCause.getCause()) { stackTraces.add(new StackTraceRepresentation(currentCause)); } return stackTraces; } }
ErrorResponses { static List<StackTraceRepresentation> buildExceptionContext(Throwable cause) { List<StackTraceRepresentation> stackTraces = new ArrayList<>(); for (Throwable currentCause = cause; currentCause != null; currentCause = currentCause.getCause()) { stackTraces.add(new StackTraceRepresentation(currentCause)); } return stackTraces; } private  ErrorResponses(); }
ErrorResponses { static List<StackTraceRepresentation> buildExceptionContext(Throwable cause) { List<StackTraceRepresentation> stackTraces = new ArrayList<>(); for (Throwable currentCause = cause; currentCause != null; currentCause = currentCause.getCause()) { stackTraces.add(new StackTraceRepresentation(currentCause)); } return stackTraces; } private  ErrorResponses(); static ErrorResponse noRequestBody(HttpServletRequest httpServletRequest); static ErrorResponse badRequest(HttpServletRequest httpServletRequest, String message); static ErrorResponse badRequest(HttpServletRequest httpServletRequest, String message, Exception cause); static ErrorResponse badRequest(HttpServletRequest httpServletRequest, Exception cause); static ErrorResponse internalServerError(HttpServletRequest httpServletRequest, Exception cause); static void sendError(HttpServletResponse httpServletResponse, ErrorResponse.ErrorResponseBuilder errorResponseBuilder); static void sendError(HttpServletResponse httpServletResponse, ErrorResponse errorResponse); static Map<String, Object> buildWebRequestContext(WebRequest webRequest); }
ErrorResponses { static List<StackTraceRepresentation> buildExceptionContext(Throwable cause) { List<StackTraceRepresentation> stackTraces = new ArrayList<>(); for (Throwable currentCause = cause; currentCause != null; currentCause = currentCause.getCause()) { stackTraces.add(new StackTraceRepresentation(currentCause)); } return stackTraces; } private  ErrorResponses(); static ErrorResponse noRequestBody(HttpServletRequest httpServletRequest); static ErrorResponse badRequest(HttpServletRequest httpServletRequest, String message); static ErrorResponse badRequest(HttpServletRequest httpServletRequest, String message, Exception cause); static ErrorResponse badRequest(HttpServletRequest httpServletRequest, Exception cause); static ErrorResponse internalServerError(HttpServletRequest httpServletRequest, Exception cause); static void sendError(HttpServletResponse httpServletResponse, ErrorResponse.ErrorResponseBuilder errorResponseBuilder); static void sendError(HttpServletResponse httpServletResponse, ErrorResponse errorResponse); static Map<String, Object> buildWebRequestContext(WebRequest webRequest);  }