@Override public String print(final int indent) { return route.print(indent); }
@Override public String print() { return route.print(); }
/** * Print route information like: method, path, source, etc... Useful for debugging. * * @return Output. */ @Nonnull default String print() { return print(0); } }
req.method(), req.path(), req.route().print(6), err); rsp.type(MediaType.html).send(writer.toString());
private void handleErr(final RequestImpl req, final ResponseImpl rsp, final Throwable ex) { Logger log = LoggerFactory.getLogger(HttpHandler.class); try { log.debug("execution of: {}{} resulted in exception", req.method(), req.path(), ex); // execution failed, find status code Status status = sc.apply(ex); if (status == Status.REQUESTED_RANGE_NOT_SATISFIABLE) { String range = rsp.header("Content-Length").toOptional().map(it -> "bytes */" + it) .orElse("*"); rsp.reset(); rsp.header("Content-Range", range); } else { rsp.reset(); } rsp.header("Cache-Control", NO_CACHE); rsp.status(status); Err err = ex instanceof Err ? (Err) ex : new Err(status, ex); Iterator<Handler> it = this.err.iterator(); while (!rsp.committed() && it.hasNext()) { Err.Handler next = it.next(); log.debug("handling err with: {}", next); next.handle(req, rsp, err); } } catch (Throwable errex) { log.error("error handler resulted in exception: {}{}\nRoute:\n{}\n\nStacktrace:\n{}\nSource:", req.method(), req.path(), req.route().print(6), Throwables.getStackTraceAsString(errex), ex); } }
@Override public void handle(final Request req, final Response rsp, final Err ex) throws Throwable { log.error("execution of: {}{} resulted in exception\nRoute:\n{}\n\nStacktrace:", req.method(), req.path(), req.route().print(6), ex); Config conf = req.require(Config.class); boolean stackstrace = Try.apply(() -> conf.getBoolean("err.stacktrace")) .orElse(req.require(Env.class).name().equals("dev")); rsp.send( Results .when(MediaType.html, () -> Results.html(VIEW).put("err", ex.toMap(stackstrace))) .when(MediaType.all, () -> ex.toMap(stackstrace))); }
@Override public String print(final int indent) { return route.print(indent); }
@Override public String print() { return route.print(); }
/** * Print route information like: method, path, source, etc... Useful for debugging. * * @return Output. */ @Nonnull default String print() { return print(0); } }
private void handleErr(final RequestImpl req, final ResponseImpl rsp, final Throwable ex) { Logger log = LoggerFactory.getLogger(HttpHandler.class); try { log.debug("execution of: {}{} resulted in exception", req.method(), req.path(), ex); // execution failed, find status code Status status = sc.apply(ex); if (status == Status.REQUESTED_RANGE_NOT_SATISFIABLE) { String range = rsp.header("Content-Length").toOptional().map(it -> "bytes */" + it) .orElse("*"); rsp.reset(); rsp.header("Content-Range", range); } else { rsp.reset(); } rsp.header("Cache-Control", NO_CACHE); rsp.status(status); Err err = ex instanceof Err ? (Err) ex : new Err(status, ex); Iterator<Handler> it = this.err.iterator(); while (!rsp.committed() && it.hasNext()) { Err.Handler next = it.next(); log.debug("handling err with: {}", next); next.handle(req, rsp, err); } } catch (Throwable errex) { log.error("error handler resulted in exception: {}{}\nRoute:\n{}\n\nStacktrace:\n{}\nSource:", req.method(), req.path(), req.route().print(6), Throwables.getStackTraceAsString(errex), ex); } }
req.method(), req.path(), req.route().print(6), err); rsp.type(MediaType.html).send(writer.toString());
@Override public void handle(final Request req, final Response rsp, final Err ex) throws Throwable { log.error("execution of: {}{} resulted in exception\nRoute:\n{}\n\nStacktrace:", req.method(), req.path(), req.route().print(6), ex); Config conf = req.require(Config.class); boolean stackstrace = Try.apply(() -> conf.getBoolean("err.stacktrace")) .orElse(req.require(Env.class).name().equals("dev")); rsp.send( Results .when(MediaType.html, () -> Results.html(VIEW).put("err", ex.toMap(stackstrace))) .when(MediaType.all, () -> ex.toMap(stackstrace))); }