Compare commits

..

No commits in common. "41fd16e5d3ad94b2461d93cee104a4eacd7ebad1" and "c73d6a1b27345fc95262472f39c12a37707c92de" have entirely different histories.

View File

@ -11,7 +11,6 @@ import org.springframework.web.HttpRequestMethodNotSupportedException;
import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestControllerAdvice; import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.multipart.MaxUploadSizeExceededException;
import org.springframework.web.servlet.resource.NoResourceFoundException; import org.springframework.web.servlet.resource.NoResourceFoundException;
/** /**
@ -33,24 +32,13 @@ public class GlobalExceptionHandler {
return WVPResult.fail(ErrorCode.ERROR500.getCode(), e.getMessage()); return WVPResult.fail(ErrorCode.ERROR500.getCode(), e.getMessage());
} }
/**
* 默认异常处理
* @param e 异常
* @return 统一返回结果
*/
@ExceptionHandler(MaxUploadSizeExceededException.class)
@ResponseStatus(HttpStatus.FORBIDDEN)
public WVPResult<String> exceptionHandler(MaxUploadSizeExceededException e) {
return WVPResult.fail(ErrorCode.ERROR403.getCode(), "文件过大");
}
/** /**
* 默认异常处理 * 默认异常处理
* @param e 异常 * @param e 异常
* @return 统一返回结果 * @return 统一返回结果
*/ */
@ExceptionHandler(NoResourceFoundException.class) @ExceptionHandler(NoResourceFoundException.class)
@ResponseStatus(HttpStatus.NOT_FOUND) @ResponseStatus(HttpStatus.BAD_REQUEST)
public WVPResult<String> exceptionHandler(NoResourceFoundException e) { public WVPResult<String> exceptionHandler(NoResourceFoundException e) {
return WVPResult.fail(ErrorCode.ERROR404); return WVPResult.fail(ErrorCode.ERROR404);
} }