diff --git a/youlai-common/common-core/src/main/java/com/youlai/common/result/ResultCode.java b/youlai-common/common-core/src/main/java/com/youlai/common/result/ResultCode.java index 656029c72..56173dbdb 100644 --- a/youlai-common/common-core/src/main/java/com/youlai/common/result/ResultCode.java +++ b/youlai-common/common-core/src/main/java/com/youlai/common/result/ResultCode.java @@ -30,7 +30,7 @@ public enum ResultCode implements IResultCode, Serializable { AUTHORIZED_ERROR("A0300", "访问权限异常"), ACCESS_UNAUTHORIZED("A0301", "访问未授权"), - FORBIDDEN_OPERATION("A0302", "演示环境禁止修改、删除重要数据,请本地部署后测试"), + FORBIDDEN_OPERATION("A0302", "演示环境禁止新增、修改和删除重要数据,请本地部署后测试"), PARAM_ERROR("A0400", "用户请求参数错误"), diff --git a/youlai-common/common-web/src/main/java/com/youlai/common/web/exception/GlobalExceptionHandler.java b/youlai-common/common-web/src/main/java/com/youlai/common/web/exception/GlobalExceptionHandler.java index d863789a2..11e4f37e4 100644 --- a/youlai-common/common-web/src/main/java/com/youlai/common/web/exception/GlobalExceptionHandler.java +++ b/youlai-common/common-web/src/main/java/com/youlai/common/web/exception/GlobalExceptionHandler.java @@ -144,9 +144,6 @@ public class GlobalExceptionHandler { return Result.failed(errorMessage); } - /** - * TypeMismatchException - */ @ResponseStatus(HttpStatus.BAD_REQUEST) @ExceptionHandler(TypeMismatchException.class) public Result processException(TypeMismatchException e) { @@ -160,7 +157,7 @@ public class GlobalExceptionHandler { String errorMsg = e.getMessage(); log.error(errorMsg); if (StrUtil.isNotBlank(errorMsg) && errorMsg.contains("denied to user")) { - return Result.failed("数据库用户无操作权限,建议本地搭建数据库环境"); + return Result.failed(ResultCode.FORBIDDEN_OPERATION); } else { return Result.failed(e.getMessage()); } @@ -195,8 +192,13 @@ public class GlobalExceptionHandler { @ResponseStatus(HttpStatus.BAD_REQUEST) @ExceptionHandler(Exception.class) public Result handleException(Exception e) { - log.error("unknown exception:{}", e.getMessage()); - return Result.failed(e.getMessage()); + String errorMsg = e.getMessage(); + if (StrUtil.isNotBlank(errorMsg) && errorMsg.contains("denied to user")) { + return Result.failed(ResultCode.FORBIDDEN_OPERATION); + }else{ + log.error("unknown exception:{}", e.getMessage()); + return Result.failed(e.getMessage()); + } } /**