From 4707718692321e7995e934c48f9b4b980b57bdc7 Mon Sep 17 00:00:00 2001 From: xiangwbs Date: Tue, 20 Mar 2018 22:25:27 +0800 Subject: [PATCH] merge --- .../xwbing/handler/GlobalExceptionHandler.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/boot-web/src/main/java/com/xwbing/handler/GlobalExceptionHandler.java b/boot-web/src/main/java/com/xwbing/handler/GlobalExceptionHandler.java index 06207d7..d04d1ed 100644 --- a/boot-web/src/main/java/com/xwbing/handler/GlobalExceptionHandler.java +++ b/boot-web/src/main/java/com/xwbing/handler/GlobalExceptionHandler.java @@ -2,6 +2,7 @@ package com.xwbing.handler; import com.alibaba.fastjson.JSONObject; import com.xwbing.exception.BusinessException; +import com.xwbing.exception.UtilException; import com.xwbing.util.JsonResult; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -49,6 +50,20 @@ public class GlobalExceptionHandler { return JsonResult.toJSONObj(ex.getMessage()); } + /** + * 自定义工具类异常 + * + * @param ex + * @return + */ + @ExceptionHandler(value = UtilException.class) + @ResponseStatus(value = HttpStatus.OK) + @ResponseBody + public JSONObject handlerUtilException(UtilException ex) { + logger.error(ex.getMessage()); + return JsonResult.toJSONObj(ex.getMessage()); + } + /** * CompletableFuture完成结果或任务过程中出现的异常 *