From 8546b3d285af4235a0ef615a0c6e89486ae2c806 Mon Sep 17 00:00:00 2001 From: fuliqi <fuliqi@qq.com> Date: 星期四, 17 十月 2024 21:01:37 +0800 Subject: [PATCH] 达梦不支持value改为values --- src/main/java/com/ycl/jxkg/config/spring/exception/ExceptionHandle.java | 17 ++++++++++++++++- 1 files changed, 16 insertions(+), 1 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 3a96ded..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,7 +27,7 @@ * Copyright (C), 2020-2024, 姝︽眽鎬濈淮璺宠穬绉戞妧鏈夐檺鍏徃 * @date 2021/12/25 9:45 */ -@ControllerAdvice +@RestControllerAdvice public class ExceptionHandle { private final static Logger logger = LoggerFactory.getLogger(ExceptionHandle.class); @@ -50,6 +51,20 @@ } /** + * 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()); + } + + /** * JSON浼犲弬鏁版嵁鏍¢獙寮傚父 * * @param e -- Gitblit v1.8.0