Commit 64cdd0e3f97c24eb88575b51efad1fb48827f7e8
1 parent
2a1e7730
异常处理类对自定义异常做单独处理;
Showing
1 changed file
with
3 additions
and
0 deletions
src/main/java/com/objecteye/exception/GeneralExceptionHandler.java
@@ -17,6 +17,9 @@ public class GeneralExceptionHandler { | @@ -17,6 +17,9 @@ public class GeneralExceptionHandler { | ||
17 | @ResponseBody | 17 | @ResponseBody |
18 | public CommonResult exception(Exception e) { | 18 | public CommonResult exception(Exception e) { |
19 | log.error(e.getMessage(), e); | 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 | return CommonResult.success(504, e.getMessage(), null); | 23 | return CommonResult.success(504, e.getMessage(), null); |
21 | } | 24 | } |
22 | } | 25 | } |