From 0b61eebf410c6f5370f3614ea8e38cb95804e87e Mon Sep 17 00:00:00 2001 From: lanyuanxiaoyao Date: Tue, 2 Jan 2024 16:12:23 +0800 Subject: [PATCH] =?UTF-8?q?feat(all):=20=E5=A2=9E=E5=8A=A0=E7=BB=9F?= =?UTF-8?q?=E4=B8=80=E7=9A=84=E5=BC=82=E5=B8=B8=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/GlobalErrorController.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 service-configuration/src/main/java/com/lanyuanxiaoyao/service/configuration/controller/GlobalErrorController.java diff --git a/service-configuration/src/main/java/com/lanyuanxiaoyao/service/configuration/controller/GlobalErrorController.java b/service-configuration/src/main/java/com/lanyuanxiaoyao/service/configuration/controller/GlobalErrorController.java new file mode 100644 index 0000000..a4c76f3 --- /dev/null +++ b/service-configuration/src/main/java/com/lanyuanxiaoyao/service/configuration/controller/GlobalErrorController.java @@ -0,0 +1,23 @@ +package com.lanyuanxiaoyao.service.configuration.controller; + +import org.springframework.http.HttpStatus; +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.ResponseStatus; + +/** + * 处理错误信息 + * + * @author lanyuanxiaoyao + * @date 2024-01-02 + */ +@ControllerAdvice +public class GlobalErrorController { + @ResponseBody + @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) + @ExceptionHandler(Throwable.class) + public String errorHandler(Throwable throwable) { + return throwable.getMessage(); + } +}