From 29ea56cf0546726a83da815ee6721090311f5567 Mon Sep 17 00:00:00 2001
From: zhoushihao <zsh19950802@163.com>
Date: 星期四, 18 四月 2024 14:09:37 +0800
Subject: [PATCH] fixbug:代码误删版本回退

---
 hangzhoumesParent/common/servicebase/src/main/java/com/mes/common/exception/GlobalExceptionHandler.java |   32 ++++++++++++++++++++++++++++++++
 1 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/hangzhoumesParent/common/servicebase/src/main/java/com/mes/common/exception/GlobalExceptionHandler.java b/hangzhoumesParent/common/servicebase/src/main/java/com/mes/common/exception/GlobalExceptionHandler.java
new file mode 100644
index 0000000..2d10ece
--- /dev/null
+++ b/hangzhoumesParent/common/servicebase/src/main/java/com/mes/common/exception/GlobalExceptionHandler.java
@@ -0,0 +1,32 @@
+package com.mes.common.exception;
+
+import com.mes.utils.Result;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.ControllerAdvice;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+/**
+ * @author zhoush
+ * @Date 2024/1/26 15:31
+ */
+@ControllerAdvice
+@Slf4j
+public class GlobalExceptionHandler {
+    /**
+     * 濡傛灉鏄痵erviceExcaption锛屽垯璋冪敤璇ユ柟娉�
+     */
+    @ExceptionHandler(ServiceException.class)
+    @ResponseBody
+    public Result handle(ServiceException se) {
+        return Result.error(se.getCode(), se.getMessage());
+    }
+
+    @ExceptionHandler(Exception.class)
+    @ResponseBody
+    public Result<Object> error(Exception e) {
+        e.printStackTrace();
+        return Result.error();
+    }
+
+}

--
Gitblit v1.8.0