967fa8ce by chentao

no message

1 parent dd6d264b
...@@ -25,6 +25,7 @@ import org.springframework.web.method.annotation.MethodArgumentTypeMismatchExcep ...@@ -25,6 +25,7 @@ import org.springframework.web.method.annotation.MethodArgumentTypeMismatchExcep
25 import javax.servlet.http.HttpServletRequest; 25 import javax.servlet.http.HttpServletRequest;
26 import javax.validation.ConstraintViolation; 26 import javax.validation.ConstraintViolation;
27 import javax.validation.ConstraintViolationException; 27 import javax.validation.ConstraintViolationException;
28 import java.util.Objects;
28 29
29 /** 30 /**
30 * 全局异常处理器 31 * 全局异常处理器
...@@ -186,9 +187,15 @@ public class GlobalExceptionHandler { ...@@ -186,9 +187,15 @@ public class GlobalExceptionHandler {
186 @ExceptionHandler(MethodArgumentNotValidException.class) 187 @ExceptionHandler(MethodArgumentNotValidException.class)
187 public R<Void> handleMethodArgumentNotValidException(MethodArgumentNotValidException e) { 188 public R<Void> handleMethodArgumentNotValidException(MethodArgumentNotValidException e) {
188 log.error(e.getMessage()); 189 log.error(e.getMessage());
190 if(Objects.nonNull(e.getBindingResult().getFieldError())) {
189 String message = e.getBindingResult().getFieldError().getDefaultMessage(); 191 String message = e.getBindingResult().getFieldError().getDefaultMessage();
190 return R.fail(message); 192 return R.fail(message);
191 } 193 }
194 else{
195 String message = "2D和3D不能都为空";
196 return R.fail(message);
197 }
198 }
192 199
193 /** 200 /**
194 * 演示模式异常 201 * 演示模式异常
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!