summaryrefslogtreecommitdiff
path: root/src/main/java/com/example/simpleminio/handler
diff options
context:
space:
mode:
authorjiang shan <[email protected]>2022-01-19 17:40:37 +0800
committerjiang shan <[email protected]>2022-01-19 17:40:37 +0800
commit8f0bcae99ff94413324947d89d7162eb440c3545 (patch)
tree3f5493d21acf6df5c995fc748b4e78aa73e21b65 /src/main/java/com/example/simpleminio/handler
miniomaster
Diffstat (limited to 'src/main/java/com/example/simpleminio/handler')
-rw-r--r--src/main/java/com/example/simpleminio/handler/GlobalExceptionHandler.java23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/main/java/com/example/simpleminio/handler/GlobalExceptionHandler.java b/src/main/java/com/example/simpleminio/handler/GlobalExceptionHandler.java
new file mode 100644
index 0000000..d9de3ea
--- /dev/null
+++ b/src/main/java/com/example/simpleminio/handler/GlobalExceptionHandler.java
@@ -0,0 +1,23 @@
+package com.example.simpleminio.handler;
+
+
+import com.example.simpleminio.util.R;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+import org.springframework.web.bind.annotation.RestControllerAdvice;
+
+@RestControllerAdvice
+@Slf4j
+public class GlobalExceptionHandler {
+ /**
+ * 全局异常处理,返回统一格式异常
+ *
+ * @param e Exception异常
+ * @return msg
+ */
+ @ExceptionHandler(Exception.class)
+ public R handler(Exception e) {
+ log.error("全局异常: ",e);
+ return R.error(e.getMessage());
+ }
+} \ No newline at end of file