| | |
| | | import com.ruoyi.common.exception.DemoModeException; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | |
| | | import javax.validation.ConstraintViolationException; |
| | | |
| | | /** |
| | | * 全局异常处理器 |
| | | * |
| | |
| | | /** |
| | | * 自定义验证异常 |
| | | */ |
| | | @ExceptionHandler(ConstraintViolationException.class) |
| | | public AjaxResult constraintViolationException(ConstraintViolationException e) { |
| | | log.error(e.getMessage(), e); |
| | | String message = e.getConstraintViolations().iterator().next().getMessage(); |
| | | return AjaxResult.error(message); |
| | | } |
| | | |
| | | /** |
| | | * 自定义验证异常 |
| | | */ |
| | | @ExceptionHandler(MethodArgumentNotValidException.class) |
| | | public Object validExceptionHandler(MethodArgumentNotValidException e) |
| | | { |