2 Commits

Author SHA1 Message Date
Acechengui
0e0075cd6c Pre Merge pull request !352 from Acechengui/N/A 2025-03-06 03:10:10 +00:00
Acechengui
e44d400366 feat:针对sql异常的高优先级的异常处理
Signed-off-by: Acechengui <623169670@qq.com>
2023-12-04 03:09:02 +00:00

View File

@@ -0,0 +1,31 @@
package com.ruoyi.common.security.handler;
import com.ruoyi.common.core.web.domain.AjaxResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import javax.servlet.http.HttpServletRequest;
import java.sql.SQLException;
/**
* @description 高优先级的异常处理
* @author Acechengui
* @date Created in 2023-08-29
*/
@Order(Ordered.HIGHEST_PRECEDENCE)
@RestControllerAdvice
public class HighestGlobalExceptionHandler {
private static final Logger log = LoggerFactory.getLogger(HighestGlobalExceptionHandler.class);
@ExceptionHandler(SQLException.class)
public AjaxResult handleSQLException(SQLException e, HttpServletRequest request) {
String requestURI = request.getRequestURI();
log.error("请求地址'{}',发生脚本执行异常.", requestURI, e);
return AjaxResult.error("发生了数据库异常");
}
}