Skip to content

Commit e17d5db

Browse files
committed
chore: 优化全局异常配置,状态信息不再显示原生异常错误信息
1 parent 9e91f56 commit e17d5db

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public R handleBusinessException(BusinessException e, HttpServletRequest request
5454
*/
5555
@ExceptionHandler(BadRequestException.class)
5656
public R handleBadRequestException(BadRequestException e, HttpServletRequest request) {
57-
log.warn("请求地址 [{}],自定义验证失败。", request.getRequestURI(), e);
57+
log.error("请求地址 [{}],自定义验证失败。", request.getRequestURI(), e);
5858
return R.fail(String.valueOf(HttpStatus.BAD_REQUEST.value()), e.getMessage());
5959
}
6060

@@ -81,7 +81,7 @@ public R handleRequestTooBigException(MultipartException e, HttpServletRequest r
8181
return defaultFail;
8282
}
8383
String errorMsg = "请上传小于 %sKB 的文件".formatted(NumberUtil.parseLong(sizeLimit) / 1024);
84-
log.warn("请求地址 [{}],上传文件失败,文件大小超过限制。", request.getRequestURI(), e);
84+
log.error("请求地址 [{}],上传文件失败,文件大小超过限制。", request.getRequestURI(), e);
8585
return R.fail(String.valueOf(HttpStatus.BAD_REQUEST.value()), errorMsg);
8686
}
8787
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ public class GlobalSaTokenExceptionHandler {
4545
public R handleNotLoginException(NotLoginException e, HttpServletRequest request) {
4646
log.error("请求地址 [{}],认证失败,无法访问系统资源。", request.getRequestURI(), e);
4747
String errorMsg = switch (e.getType()) {
48-
case NotLoginException.KICK_OUT -> "您已被踢下线";
49-
case NotLoginException.BE_REPLACED_MESSAGE -> "您已被顶下线";
50-
default -> "您的登录状态已过期,请重新登录";
48+
case NotLoginException.KICK_OUT -> "您已被踢下线";
49+
case NotLoginException.BE_REPLACED_MESSAGE -> "您已被顶下线";
50+
default -> "您的登录状态已过期,请重新登录";
5151
};
5252
return R.fail(String.valueOf(HttpStatus.UNAUTHORIZED.value()), errorMsg);
5353
}

continew-admin-webapi/src/main/resources/config/application.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ continew-starter.web:
6161
default-error-code: 1
6262
# 自定义失败提示(默认:error)
6363
default-error-msg: error
64+
# 是否将原生异常错误信息填充到状态信息中
65+
origin-exception-using-detail-message: false
6466

6567
--- ### 接口文档配置
6668
springdoc:

0 commit comments

Comments
 (0)