diff --git a/src/main/java/com/genersoft/iot/vmp/conf/GlobalExceptionHandler.java b/src/main/java/com/genersoft/iot/vmp/conf/GlobalExceptionHandler.java index da0844d2b..b0137a25f 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/GlobalExceptionHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/GlobalExceptionHandler.java @@ -11,6 +11,7 @@ import org.springframework.web.HttpRequestMethodNotSupportedException; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestControllerAdvice; +import org.springframework.web.multipart.MaxUploadSizeExceededException; import org.springframework.web.servlet.resource.NoResourceFoundException; /** @@ -32,13 +33,24 @@ public class GlobalExceptionHandler { return WVPResult.fail(ErrorCode.ERROR500.getCode(), e.getMessage()); } + /** + * 默认异常处理 + * @param e 异常 + * @return 统一返回结果 + */ + @ExceptionHandler(MaxUploadSizeExceededException.class) + @ResponseStatus(HttpStatus.FORBIDDEN) + public WVPResult exceptionHandler(MaxUploadSizeExceededException e) { + return WVPResult.fail(ErrorCode.ERROR403); + } + /** * 默认异常处理 * @param e 异常 * @return 统一返回结果 */ @ExceptionHandler(NoResourceFoundException.class) - @ResponseStatus(HttpStatus.BAD_REQUEST) + @ResponseStatus(HttpStatus.NOT_FOUND) public WVPResult exceptionHandler(NoResourceFoundException e) { return WVPResult.fail(ErrorCode.ERROR404); }