lyhzzz 2 年之前
父节点
当前提交
25625665ba
共有 1 个文件被更改,包括 36 次插入36 次删除
  1. 36 36
      src/main/java/com/fdkankan/ucenter/exception/GlobalExceptionHandler.java

+ 36 - 36
src/main/java/com/fdkankan/ucenter/exception/GlobalExceptionHandler.java

@@ -1,36 +1,36 @@
-//package com.fdkankan.ucenter.exception;
-//
-//import com.fdkankan.common.exception.BusinessException;
-//import com.fdkankan.ucenter.common.Result;
-//import lombok.extern.slf4j.Slf4j;
-//import org.springframework.web.bind.annotation.ExceptionHandler;
-//import org.springframework.web.bind.annotation.ResponseBody;
-//import org.springframework.web.bind.annotation.RestControllerAdvice;
-//
-///**
-// * 全局异常处理器
-// */
-//@RestControllerAdvice
-//@Slf4j
-//public class GlobalExceptionHandler {
-//
-//    /**
-//     * 处理未知异常
-//     */
-//    @ResponseBody
-//    @ExceptionHandler(value = Exception.class)
-//    public Result exceptionHandler(Exception e) throws Exception {
-//        log.error("服务错误:", e);
-//        return Result.failure( 500, e.getMessage());
-//    }
-//
-//    /**
-//     * 处理业务异常
-//     */
-//    @ResponseBody
-//    @ExceptionHandler(value = BusinessException.class)
-//    public Result businessExceptionHandler(BusinessException e) {
-//        log.info("业务异常code:{},message:{}", e.getCode(), e.getMessage());
-//        return Result.failure(e.getCode(), e.getMessage());
-//    }
-//}
+package com.fdkankan.ucenter.exception;
+
+import com.fdkankan.common.exception.BusinessException;
+import com.fdkankan.ucenter.common.Result;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.RestControllerAdvice;
+
+/**
+ * 全局异常处理器
+ */
+@RestControllerAdvice
+@Slf4j
+public class GlobalExceptionHandler {
+
+    /**
+     * 处理未知异常
+     */
+    @ResponseBody
+    @ExceptionHandler(value = Exception.class)
+    public Result exceptionHandler(Exception e) throws Exception {
+        log.error("服务错误:", e);
+        return Result.failure( 500, e.getMessage());
+    }
+
+    /**
+     * 处理业务异常
+     */
+    @ResponseBody
+    @ExceptionHandler(value = BusinessException.class)
+    public Result businessExceptionHandler(BusinessException e) {
+        log.info("业务异常code:{},message:{}", e.getCode(), e.getMessage());
+        return Result.failure(e.getCode(), e.getMessage());
+    }
+}