Commit 64cdd0e3f97c24eb88575b51efad1fb48827f7e8

Authored by Liu Haoyu
1 parent 2a1e7730

异常处理类对自定义异常做单独处理;

src/main/java/com/objecteye/exception/GeneralExceptionHandler.java
... ... @@ -17,6 +17,9 @@ public class GeneralExceptionHandler {
17 17 @ResponseBody
18 18 public CommonResult exception(Exception e) {
19 19 log.error(e.getMessage(), e);
  20 + if (e instanceof CustomXException) {
  21 + return CommonResult.success(Integer.parseInt(((CustomXException) e).getCode()), ((CustomXException) e).getMsg(), null);
  22 + }
20 23 return CommonResult.success(504, e.getMessage(), null);
21 24 }
22 25 }
... ...