private void handleError(RequestContext ctx, Exception e) throws IOException, ServletException { ctx.getRequest().setAttribute(ExceptionHandler.KEY_IN_REQUEST, e); if (exceptionHandler != null) { try { exceptionHandler.handleError(ctx, e); return; } catch (Exception ex) { e = ex; } } if (e instanceof RuntimeException) { throw (RuntimeException) e; } if (e instanceof IOException) { throw (IOException) e; } if (e instanceof ServletException) { throw (ServletException) e; } throw new ServletException(e); }