|
@@ -44,7 +44,8 @@ import org.springframework.web.bind.annotation.ExceptionHandler;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
|
|
import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException;
|
|
|
-import org.springframework.web.multipart.MaxUploadSizeExceededException;
|
|
|
+import org.springframework.web.multipart.MultipartException;
|
|
|
+import org.springframework.web.multipart.support.MissingServletRequestPartException;
|
|
|
|
|
|
/**
|
|
|
* 异常处理拦截器
|
|
@@ -146,7 +147,7 @@ public class GlobalExceptionInterceptor implements ErrorController {
|
|
|
return CollectionUtils.isEmpty(errors) ? Result.build(HttpStatus.BAD_REQUEST) :
|
|
|
Result.build(HttpStatus.PRECONDITION_FAILED, errors);
|
|
|
} else if (e instanceof HttpMessageConversionException || e instanceof ServletRequestBindingException
|
|
|
- || e instanceof MaxUploadSizeExceededException) {
|
|
|
+ || e instanceof MultipartException) {
|
|
|
return Result.build(HttpStatus.BAD_REQUEST);
|
|
|
} else if (e instanceof ResourceInvalidException) {
|
|
|
String code = ((ResourceInvalidException) e).getCode();
|
|
@@ -164,6 +165,10 @@ public class GlobalExceptionInterceptor implements ErrorController {
|
|
|
return Result.build(HttpStatus.PRECONDITION_FAILED, this.format((MethodArgumentTypeMismatchException) e));
|
|
|
} else if (e instanceof ParameterInvalidException) {
|
|
|
return Result.build(HttpStatus.PRECONDITION_FAILED, ((ParameterInvalidException) e).getErrors());
|
|
|
+ } else if (e instanceof MissingServletRequestPartException) {
|
|
|
+ return Result.build(HttpStatus.PRECONDITION_FAILED, ImmutableMap.of(
|
|
|
+ ((MissingServletRequestPartException) e).getRequestPartName(), e.getMessage()
|
|
|
+ ));
|
|
|
} else if (e instanceof BusinessException) {
|
|
|
return Result.build(((BusinessException) e).getStatus(), ((BusinessException) e).getData(), e.getMessage());
|
|
|
}
|