|
|
|
@ -7,6 +7,7 @@ import com.glxp.api.common.util.ResultVOUtils;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.http.converter.HttpMessageNotReadableException;
|
|
|
|
|
import org.springframework.validation.BindException;
|
|
|
|
|
import org.springframework.web.bind.MethodArgumentNotValidException;
|
|
|
|
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
|
|
|
|
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
|
|
|
|
|
|
|
|
@ -34,12 +35,21 @@ public class GlobalExceptionHandler {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ExceptionHandler({BindException.class})
|
|
|
|
|
public BaseResponse handlerBindException(BindException e) {
|
|
|
|
|
log.error(e.getMessage(), e);
|
|
|
|
|
boolean bindingFailure = e.getFieldError().isBindingFailure();
|
|
|
|
|
if(bindingFailure){
|
|
|
|
|
if (bindingFailure) {
|
|
|
|
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL);
|
|
|
|
|
}
|
|
|
|
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, e.getBindingResult().getFieldError().getDefaultMessage());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ExceptionHandler({MethodArgumentNotValidException.class})
|
|
|
|
|
public BaseResponse handlerBindException(MethodArgumentNotValidException e) {
|
|
|
|
|
log.error(e.getMessage(), e);
|
|
|
|
|
boolean bindingFailure = e.getBindingResult().getFieldError().isBindingFailure();
|
|
|
|
|
if (bindingFailure) {
|
|
|
|
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL);
|
|
|
|
|
}
|
|
|
|
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, e.getBindingResult().getFieldError().getDefaultMessage());
|
|
|
|
|