Skip to content

Commit

Permalink
增加MethodArgumentTypeMismatchException异常处理
Browse files Browse the repository at this point in the history
  • Loading branch information
zhoutaoo committed Feb 8, 2024
1 parent e0c4126 commit 1039068
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
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.method.annotation.MethodArgumentTypeMismatchException;
import org.springframework.web.multipart.MultipartException;

/**
Expand All @@ -36,7 +37,7 @@ public Result argumentInvalidException(MethodArgumentNotValidException ex) {
return Result.fail(SystemErrorType.ARGUMENT_NOT_VALID, ex.getBindingResult().getFieldError().getDefaultMessage());
}

@ExceptionHandler(value = {HttpMessageNotReadableException.class})
@ExceptionHandler(value = {HttpMessageNotReadableException.class, MethodArgumentTypeMismatchException.class})
public Result httpMessageConvertException(HttpMessageNotReadableException ex) {
log.warn("http message convert exception:{}", ex.getMessage());
return Result.fail(SystemErrorType.ARGUMENT_NOT_VALID, "数据解析错误:" + ex.getMessage());
Expand Down

0 comments on commit 1039068

Please sign in to comment.