update > controller template & exception handler for issue #13

master
lihengming 7 years ago
parent 1e8e1bdd6a
commit 67cf9dfbf8
  1. 4
      src/main/java/com/company/project/configurer/WebMvcConfigurer.java

@ -71,6 +71,7 @@ public class WebMvcConfigurer extends WebMvcConfigurerAdapter {
} else if (e instanceof ServletException) { } else if (e instanceof ServletException) {
result.setCode(ResultCode.FAIL).setMessage(e.getMessage()); result.setCode(ResultCode.FAIL).setMessage(e.getMessage());
} else { } else {
result.setCode(ResultCode.INTERNAL_SERVER_ERROR).setMessage("接口 [" + request.getRequestURI() + "] 内部错误,请联系管理员");
String message; String message;
if (handler instanceof HandlerMethod) { if (handler instanceof HandlerMethod) {
HandlerMethod handlerMethod = (HandlerMethod) handler; HandlerMethod handlerMethod = (HandlerMethod) handler;
@ -82,8 +83,7 @@ public class WebMvcConfigurer extends WebMvcConfigurerAdapter {
} else { } else {
message = e.getMessage(); message = e.getMessage();
} }
result.setCode(ResultCode.INTERNAL_SERVER_ERROR).setMessage(message); logger.error(message, e);
logger.error(e.getMessage(), e);
} }
responseResult(response, result); responseResult(response, result);
return new ModelAndView(); return new ModelAndView();

Loading…
Cancel
Save