@Override public FullHttpResponse onView(ViewBody body) { try { var sw = new StringWriter(); WebContext.blade().templateEngine().render(body.modelAndView(), sw); WebContext.response().contentType(Const.CONTENT_TYPE_HTML); return this.onByteBuf(Unpooled.copiedBuffer(sw.toString().getBytes(StandardCharsets.UTF_8))); } catch (Exception e) { log.error("Render view error", e); } return null; }
@Override public FullHttpResponse onView(ViewBody body) { try { var sw = new StringWriter(); WebContext.blade().templateEngine().render(body.modelAndView(), sw); WebContext.response().contentType(Const.CONTENT_TYPE_HTML); return this.onByteBuf(Unpooled.copiedBuffer(sw.toString().getBytes(StandardCharsets.UTF_8))); } catch (Exception e) { log.error("Render view error", e); } return null; }
@Override public void handle(Exception e) { if (!ExceptionHandler.isResetByPeer(e)) { var response = WebContext.response(); var request = WebContext.request(); if (e instanceof BladeException) { this.handleBladeException((BladeException) e, request, response); } else if (ValidatorException.class.isInstance(e)) { this.handleValidators(ValidatorException.class.cast(e), request, response); } else { this.handleException(e, request, response); } } }
@Override public void handle(Exception e) { if (!ExceptionHandler.isResetByPeer(e)) { var response = WebContext.response(); var request = WebContext.request(); if (e instanceof BladeException) { this.handleBladeException((BladeException) e, request, response); } else if (ValidatorException.class.isInstance(e)) { this.handleValidators(ValidatorException.class.cast(e), request, response); } else { this.handleException(e, request, response); } } }
private FullHttpResponse handleException(Throwable e) { Request request = WebContext.request(); Response response = WebContext.response(); String method = request.method(); String uri = request.uri(); Exception srcException = (Exception) e.getCause().getCause(); if (srcException instanceof BladeException) { } else { log500(log, method, uri); } if (null != WebContext.blade().exceptionHandler()) { WebContext.blade().exceptionHandler().handle(srcException); } else { log.error("", srcException); } return routeHandler.handleResponse( request, response, WebContext.get().getChannelHandlerContext() ); }
private FullHttpResponse handleException(Throwable e) { Request request = WebContext.request(); Response response = WebContext.response(); String method = request.method(); String uri = request.uri(); Exception srcException = (Exception) e.getCause().getCause(); if (srcException instanceof BladeException) { } else { log500(log, method, uri); } if (null != WebContext.blade().exceptionHandler()) { WebContext.blade().exceptionHandler().handle(srcException); } else { log.error("", srcException); } return routeHandler.handleResponse( request, response, WebContext.get().getChannelHandlerContext() ); }
@Override public FullHttpResponse onView(ViewBody body) { try { var sw = new StringWriter(); WebContext.blade().templateEngine().render(body.modelAndView(), sw); WebContext.response().contentType(Const.CONTENT_TYPE_HTML); return this.onByteBuf(Unpooled.copiedBuffer(sw.toString().getBytes(StandardCharsets.UTF_8))); } catch (Exception e) { log.error("Render view error", e); } return null; }
@Override public void handle(Exception e) { if (!ExceptionHandler.isResetByPeer(e)) { var response = WebContext.response(); var request = WebContext.request(); if (e instanceof BladeException) { this.handleBladeException((BladeException) e, request, response); } else if (ValidatorException.class.isInstance(e)) { this.handleValidators(ValidatorException.class.cast(e), request, response); } else { this.handleException(e, request, response); } } }
@Override public void handle(Exception e) { if (e instanceof ValidateException) { ValidateException validateException = (ValidateException) e; String msg = validateException.getErrMsg(); WebContext.response().json(RestResponse.fail(msg)); } else { super.handle(e); } }
private FullHttpResponse handleException(Throwable e) { Request request = WebContext.request(); Response response = WebContext.response(); String method = request.method(); String uri = request.uri(); Exception srcException = (Exception) e.getCause().getCause(); if (srcException instanceof BladeException) { } else { log500(log, method, uri); } if (null != WebContext.blade().exceptionHandler()) { WebContext.blade().exceptionHandler().handle(srcException); } else { log.error("", srcException); } return routeHandler.handleResponse( request, response, WebContext.get().getChannelHandlerContext() ); }