|
|
|
@ -1,7 +1,6 @@
|
|
|
|
|
package com.shxy.xymanager_common.exception;
|
|
|
|
|
|
|
|
|
|
import com.shxy.xymanager_common.base.ResponseReult;
|
|
|
|
|
import org.springframework.validation.BindException;
|
|
|
|
|
import org.springframework.validation.BindingResult;
|
|
|
|
|
import org.springframework.validation.FieldError;
|
|
|
|
|
import org.springframework.web.bind.MethodArgumentNotValidException;
|
|
|
|
@ -54,15 +53,8 @@ public class GlobalExceptionHandler {
|
|
|
|
|
|
|
|
|
|
@ResponseBody
|
|
|
|
|
@ExceptionHandler(value = Exception.class)
|
|
|
|
|
public ResponseReult handleValidException(BindException e) {
|
|
|
|
|
BindingResult bindingResult = e.getBindingResult();
|
|
|
|
|
String message = null;
|
|
|
|
|
if (bindingResult.hasErrors()) {
|
|
|
|
|
FieldError fieldError = bindingResult.getFieldError();
|
|
|
|
|
if (fieldError != null) {
|
|
|
|
|
message = fieldError.getField()+fieldError.getDefaultMessage();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public ResponseReult handleValidException(Exception e) {
|
|
|
|
|
String message = e.getMessage();
|
|
|
|
|
return ResponseReult.error(message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|