use of io.leopard.mvc.trynb.model.TrynbInfo in project leopard by tanhaichao.
the class TrynbHandlerExceptionResolver method resolveException.
// @PostConstruct
// public void init() {
// for (TrynbResolver trynbResolver : trynbResolverList) {
// logger.info("trynbResolver:" + trynbResolver.getClass().getName());
// }
// }
@Override
public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, Object handler, Exception exception) {
if (exception == null) {
throw new NullPointerException("exception参数怎么会为null?");
}
// logger.error("resolveException:" + exception.toString());
if (!(handler instanceof HandlerMethod)) {
return null;
}
String uri = request.getRequestURI();
TrynbInfo trynbInfo = errorPageService.parse(request, uri, exception);
ModelAndView view = resolveView(request, response, ((HandlerMethod) handler), exception, trynbInfo);
request.setAttribute("exception", exception);
// request.setAttribute("modelAndView", view);
return view;
}
use of io.leopard.mvc.trynb.model.TrynbInfo in project leopard by tanhaichao.
the class TrynbApiImpl method parse.
@Override
public TrynbInfo parse(TrynbLogger trynbLogger, HttpServletRequest request, String uri, Exception exception) {
ErrorConfig errorConfig = trynbDao.find(uri);
if (exception instanceof MethodArgumentTypeMismatchException) {
MethodArgumentTypeMismatchException e2 = (MethodArgumentTypeMismatchException) exception;
Exception e = (Exception) e2.getCause().getCause();
if (e != null) {
exception = e;
} else {
exception = (Exception) e2.getCause();
}
}
ExceptionConfig exceptionConfig = this.find(errorConfig, exception);
TrynbInfo trynbInfo = new TrynbInfo();
String message;
if (exceptionConfig == null || StringUtils.isEmpty(exceptionConfig.getMessage())) {
message = parseMessage(trynbInfo, exception);
} else {
message = exceptionConfig.getMessage();
trynbInfo.setTrynbMessage(true);
}
String statusCode = this.parseStatusCode(trynbLogger, exceptionConfig, request, uri, exception);
trynbInfo.setPage(errorConfig.getPage());
trynbInfo.setMessage(message);
trynbInfo.setException(exception);
trynbInfo.setStatusCode(statusCode);
return trynbInfo;
}
Aggregations