|
@@ -0,0 +1,24 @@
|
|
|
|
+package com.fjs.scenic.config;
|
|
|
|
+
|
|
|
|
+import com.fjs.scenic.utils.ReturnResult;
|
|
|
|
+import lombok.Data;
|
|
|
|
+import org.springframework.web.bind.annotation.ControllerAdvice;
|
|
|
|
+import org.springframework.web.bind.annotation.ExceptionHandler;
|
|
|
|
+import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * @program: fjs-parent
|
|
|
|
+ * @description: 全局异常捕获
|
|
|
|
+ * @author: lfj
|
|
|
|
+ * @since: 2021-09-30 16:15
|
|
|
|
+ **/
|
|
|
|
+
|
|
|
|
+@ControllerAdvice
|
|
|
|
+public class MyExceptionHandler {
|
|
|
|
+
|
|
|
|
+ @ExceptionHandler(value =Exception.class)
|
|
|
|
+ @ResponseBody
|
|
|
|
+ public ReturnResult exceptionHandler(Exception e){
|
|
|
|
+ return ReturnResult.error(e.getMessage());
|
|
|
|
+ }
|
|
|
|
+}
|