|
|
@@ -10,6 +10,7 @@ import org.springframework.util.Assert;
|
|
|
import org.springframework.validation.BindException;
|
|
|
import org.springframework.validation.FieldError;
|
|
|
import org.springframework.web.bind.MethodArgumentNotValidException;
|
|
|
+import org.springframework.web.bind.ServletRequestBindingException;
|
|
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
|
|
import org.springframework.web.bind.annotation.ResponseStatus;
|
|
|
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
|
|
@@ -95,7 +96,7 @@ public class GlobalBizExceptionHandler {
|
|
|
@ResponseStatus(HttpStatus.OK)
|
|
|
public R handleBodyValidException(MethodArgumentNotValidException exception) {
|
|
|
List<FieldError> fieldErrors = exception.getBindingResult().getFieldErrors();
|
|
|
- log.warn("参数绑定异常,ex = {}", fieldErrors.get(0).getDefaultMessage());
|
|
|
+ log.error("参数绑定异常,ex = {}", fieldErrors.get(0).getDefaultMessage());
|
|
|
return R.failed(String.format("%s %s", fieldErrors.get(0).getField(), fieldErrors.get(0).getDefaultMessage()));
|
|
|
}
|
|
|
|
|
|
@@ -108,7 +109,7 @@ public class GlobalBizExceptionHandler {
|
|
|
@ResponseStatus(HttpStatus.BAD_REQUEST)
|
|
|
public R bindExceptionHandler(BindException exception) {
|
|
|
List<FieldError> fieldErrors = exception.getBindingResult().getFieldErrors();
|
|
|
- log.warn("参数绑定异常,ex = {}", fieldErrors.get(0).getDefaultMessage());
|
|
|
+ log.error("参数绑定异常,ex = {}", fieldErrors.get(0).getDefaultMessage());
|
|
|
return R.failed(fieldErrors.get(0).getDefaultMessage());
|
|
|
}
|
|
|
|
|
|
@@ -132,7 +133,7 @@ public class GlobalBizExceptionHandler {
|
|
|
@ExceptionHandler({ AesDecodeException.class })
|
|
|
@ResponseStatus(HttpStatus.OK)
|
|
|
public R<Object> bindAesDecodeException(AesDecodeException exception) {
|
|
|
- log.error("解密异常:{}", exception.getMessage(), exception);
|
|
|
+ log.error("解密异常:{}", exception.getMessage());
|
|
|
return R.failed(exception.getMessage());
|
|
|
}
|
|
|
|
|
|
@@ -147,15 +148,29 @@ public class GlobalBizExceptionHandler {
|
|
|
|
|
|
return R.failed(e.getMessage());
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 参数绑定异常
|
|
|
- * @param e 错误类型
|
|
|
+ * @param exception 错误类型
|
|
|
* @return {@link R}
|
|
|
*/
|
|
|
@ExceptionHandler(HttpMessageNotReadableException.class)
|
|
|
- public R handlerParamException(HttpMessageNotReadableException e){
|
|
|
+ public R handlerParamException(HttpMessageNotReadableException exception){
|
|
|
|
|
|
- return R.failed(e.getMessage());
|
|
|
+ log.error("参数绑定异常:{}", exception.getMessage());
|
|
|
+ return R.failed(exception.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 参数绑定异常
|
|
|
+ * @param exception 错误类型
|
|
|
+ * @return {@link R}
|
|
|
+ */
|
|
|
+ @ExceptionHandler(ServletRequestBindingException.class)
|
|
|
+ public R handlerParamException(ServletRequestBindingException exception){
|
|
|
+
|
|
|
+ log.error("参数绑定异常:{}", exception.getMessage());
|
|
|
+ return R.failed(exception.getMessage());
|
|
|
}
|
|
|
|
|
|
}
|