增加全局MissingServletRequestPartException处理

This commit is contained in:
zhangtianyu 2022-04-18 18:19:28 +08:00
parent 9088cc94f3
commit 39a7252336

View File

@ -13,6 +13,7 @@ import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.MissingServletRequestParameterException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.multipart.support.MissingServletRequestPartException;
/**
* @program: oss
@ -30,6 +31,12 @@ public class ControllerExceptionHandler {
return CommonResponse.error(CodeEnum.MISSING_REQUEST_PARAM.getCode(), e.getMessage());
}
@ExceptionHandler(value = MissingServletRequestPartException.class)
public CommonResponse handleMissingRequestPart(MissingServletRequestPartException e) {
log.warn("[oss] ControllerExceptionHandler.missing servlet request part Exception", e);
return CommonResponse.error(CodeEnum.MISSING_REQUEST_PARAM.getCode(), e.getMessage());
}
@ExceptionHandler(value = BizException.class)
public CommonResponse bizException(BizException e){
log.warn("[oss] ControllerExceptionHandler.bizException Exception", e);