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());