From f298817c917dec99b1e355423fd70844a91983a7 Mon Sep 17 00:00:00 2001 From: "Captain.B" Date: Fri, 5 Feb 2021 15:38:19 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E7=BB=9F=E4=B8=80=E5=A4=84?= =?UTF-8?q?=E7=90=86sql=E5=BC=82=E5=B8=B8=EF=BC=8C=E4=B8=8D=E5=9C=A8?= =?UTF-8?q?=E5=89=8D=E5=8F=B0=E6=98=BE=E7=A4=BA=EF=BC=8C=E6=8F=90=E7=A4=BA?= =?UTF-8?q?sql=E9=94=99=E8=AF=AF=EF=BC=8C=E6=A3=80=E6=9F=A5=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/handler/RestControllerExceptionHandler.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/backend/src/main/java/io/metersphere/controller/handler/RestControllerExceptionHandler.java b/backend/src/main/java/io/metersphere/controller/handler/RestControllerExceptionHandler.java index 411ccc6c42..6534abf2fe 100644 --- a/backend/src/main/java/io/metersphere/controller/handler/RestControllerExceptionHandler.java +++ b/backend/src/main/java/io/metersphere/controller/handler/RestControllerExceptionHandler.java @@ -11,6 +11,7 @@ import org.springframework.web.bind.annotation.RestControllerAdvice; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import java.sql.SQLException; @RestControllerAdvice @@ -30,6 +31,12 @@ public class RestControllerExceptionHandler { } + @ExceptionHandler(SQLException.class) + public ResultHolder sqlExceptionHandler(HttpServletRequest request, HttpServletResponse response, MSException e) { + response.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value()); + return ResultHolder.error("SQL error happened, please check logs."); + } + @ExceptionHandler(MSException.class) public ResultHolder msExceptionHandler(HttpServletRequest request, HttpServletResponse response, MSException e) { response.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value());