| | |
| | | import org.springframework.security.access.AccessDeniedException;
|
| | | import org.springframework.security.authentication.AccountExpiredException;
|
| | | import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
| | | 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;
|
| | | import org.springframework.web.servlet.NoHandlerFoundException;
|
| | |
| | | }
|
| | |
|
| | | /**
|
| | | * 自定义验证异常
|
| | | */
|
| | | @ExceptionHandler(BindException.class)
|
| | | public AjaxResult validatedBindException(BindException e)
|
| | | {
|
| | | log.error(e.getMessage(), e);
|
| | | String message = e.getAllErrors().get(0).getDefaultMessage();
|
| | | return AjaxResult.error(message);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 自定义验证异常
|
| | | */
|
| | | @ExceptionHandler(MethodArgumentNotValidException.class)
|
| | | public Object validExceptionHandler(MethodArgumentNotValidException e)
|
| | | {
|
| | | log.error(e.getMessage(), e);
|
| | | String message = e.getBindingResult().getFieldError().getDefaultMessage();
|
| | | return AjaxResult.error(message);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 演示模式异常
|
| | | */
|
| | | @ExceptionHandler(DemoModeException.class)
|