feat: 全局异常处理器添加 BaseException 处理

This commit is contained in:
danaodai
2025-05-12 07:37:57 +00:00
committed by Charles7c
parent 5922bce0b0
commit 4274f2ede6

View File

@@ -32,6 +32,7 @@ import org.springframework.web.method.annotation.MethodArgumentTypeMismatchExcep
import org.springframework.web.multipart.MultipartException;
import org.springframework.web.servlet.NoHandlerFoundException;
import top.continew.starter.core.exception.BadRequestException;
import top.continew.starter.core.exception.BaseException;
import top.continew.starter.core.exception.BusinessException;
import top.continew.starter.web.model.R;
@@ -47,6 +48,16 @@ import top.continew.starter.web.model.R;
@RestControllerAdvice
public class GlobalExceptionHandler {
/**
* 自定义基类异常
*/
@ExceptionHandler(BaseException.class)
public R handleBaseException(BaseException e, HttpServletRequest request) {
log.error("[{}] {}", request.getMethod(), request.getRequestURI(), e);
return R.fail(String.valueOf(HttpStatus.INTERNAL_SERVER_ERROR.value()), e.getMessage());
}
/**
* 业务异常
*/