最新代码
This commit is contained in:
@@ -1,16 +1,19 @@
|
||||
package com.starry.admin.common.exception.handler;
|
||||
|
||||
|
||||
import com.fasterxml.jackson.databind.exc.MismatchedInputException;
|
||||
import com.starry.admin.common.exception.CustomException;
|
||||
import com.starry.admin.common.exception.ServiceException;
|
||||
import com.starry.common.result.R;
|
||||
import com.starry.common.utils.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.converter.HttpMessageNotReadableException;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.validation.FieldError;
|
||||
import org.springframework.web.HttpRequestMethodNotSupportedException;
|
||||
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;
|
||||
|
||||
@@ -79,6 +82,22 @@ public class GlobalExceptionHandler {
|
||||
return R.error("请求参数异常," + errorMessageBuilder);
|
||||
}
|
||||
|
||||
@ExceptionHandler(MismatchedInputException.class)
|
||||
public R mismatchedInputException(MismatchedInputException e) {
|
||||
return R.error("请求参数格式异常");
|
||||
}
|
||||
|
||||
@ExceptionHandler(HttpMessageNotReadableException.class)
|
||||
public R httpMessageNotReadableException(HttpMessageNotReadableException e) {
|
||||
return R.error("请求参数格式异常");
|
||||
}
|
||||
|
||||
@ExceptionHandler(MissingServletRequestParameterException.class)
|
||||
public R missingServletRequestParameterException(MissingServletRequestParameterException e) {
|
||||
return R.error("请求参数格式异常");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 自定义异常
|
||||
*
|
||||
@@ -89,10 +108,5 @@ public class GlobalExceptionHandler {
|
||||
return R.error(e.getMessage());
|
||||
}
|
||||
|
||||
// @ExceptionHandler(ServiceException.class)
|
||||
// public R serviceException(ServiceException e) {
|
||||
// return R.error(e.getMessage());
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user