From d0ba0324430a0010ecf47e5cc0e4df609d586cfd Mon Sep 17 00:00:00 2001
From: fuliqi <fuliqi@qq.com>
Date: 星期三, 19 六月 2024 11:31:00 +0800
Subject: [PATCH] 会议学生端查询
---
src/main/java/com/ycl/jxkg/config/spring/exception/ExceptionHandle.java | 22 ++++++++++++++++++++--
1 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/src/main/java/com/ycl/jxkg/config/spring/exception/ExceptionHandle.java b/src/main/java/com/ycl/jxkg/config/spring/exception/ExceptionHandle.java
index cc0c2c8..4f1977a 100644
--- a/src/main/java/com/ycl/jxkg/config/spring/exception/ExceptionHandle.java
+++ b/src/main/java/com/ycl/jxkg/config/spring/exception/ExceptionHandle.java
@@ -15,6 +15,7 @@
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.RestControllerAdvice;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
@@ -26,11 +27,13 @@
* Copyright (C), 2020-2024, 姝︽眽鎬濈淮璺宠穬绉戞妧鏈夐檺鍏徃
* @date 2021/12/25 9:45
*/
-@ControllerAdvice
+@RestControllerAdvice
public class ExceptionHandle {
private final static Logger logger = LoggerFactory.getLogger(ExceptionHandle.class);
- /** 鍏徃椤圭洰鐨勫寘缁撴瀯锛岀敤浜庣缉鐭敊璇棩蹇楃殑闀垮害 */
+ /**
+ * 鍏徃椤圭洰鐨勫寘缁撴瀯锛岀敤浜庣缉鐭敊璇棩蹇楃殑闀垮害
+ */
private final static String COMPANY_PACKAGE = "com.ycl.jxkg.";
/**
@@ -45,6 +48,20 @@
String errMsg = String.format("绯荤粺寮傚父-%s", e.getMessage());
this.printExceptionLocation(e, request, errMsg);
return new Result<>(SystemCode.InnerError.getCode(), SystemCode.InnerError.getMessage());
+ }
+
+ /**
+ * Handler rest response.
+ *
+ * @param e the e
+ * @return the rest response
+ */
+ @ExceptionHandler(RuntimeException.class)
+ @ResponseBody
+ public Result handler(RuntimeException e, HttpServletRequest request) {
+ String errMsg = String.format("绯荤粺寮傚父-%s", e.getMessage());
+ this.printExceptionLocation(e, request, errMsg);
+ return new Result<>(SystemCode.InnerError.getCode(), e.getMessage());
}
/**
@@ -98,6 +115,7 @@
/**
* 鎵撳嵃寮傚父鍑虹幇浣嶇疆
+ *
* @param e
*/
private void printExceptionLocation(Throwable e, HttpServletRequest request, String errMsg) {
--
Gitblit v1.8.0