Skip to content

Commit 4274f2e

Browse files
chengang1Charles7c
authored andcommitted
feat: 全局异常处理器添加 BaseException 处理
1 parent 5922bce commit 4274f2e

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

continew-common/src/main/java/top/continew/admin/common/config/exception/GlobalExceptionHandler.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import org.springframework.web.multipart.MultipartException;
3333
import org.springframework.web.servlet.NoHandlerFoundException;
3434
import top.continew.starter.core.exception.BadRequestException;
35+
import top.continew.starter.core.exception.BaseException;
3536
import top.continew.starter.core.exception.BusinessException;
3637
import top.continew.starter.web.model.R;
3738

@@ -47,6 +48,16 @@
4748
@RestControllerAdvice
4849
public class GlobalExceptionHandler {
4950

51+
52+
/**
53+
* 自定义基类异常
54+
*/
55+
@ExceptionHandler(BaseException.class)
56+
public R handleBaseException(BaseException e, HttpServletRequest request) {
57+
log.error("[{}] {}", request.getMethod(), request.getRequestURI(), e);
58+
return R.fail(String.valueOf(HttpStatus.INTERNAL_SERVER_ERROR.value()), e.getMessage());
59+
}
60+
5061
/**
5162
* 业务异常
5263
*/

0 commit comments

Comments
 (0)