| | |
| | | import org.springframework.web.bind.annotation.ExceptionHandler; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | |
| | | import java.util.Arrays; |
| | | |
| | | @ControllerAdvice |
| | | public class GlobalExceptionHandle { |
| | | /** |
| | |
| | | return Result.error(se.getCode(),se.getMessage()); |
| | | } |
| | | |
| | | // 拦截:无权限异常 |
| | | @ExceptionHandler(NotPermissionException.class) |
| | | @ResponseBody |
| | | public Result handlerException(NotPermissionException e) { |
| | | return Result.error(Constants.Code_401,"This user has no permission to access this resource"); |
| | | return Result.error(Constants.Code_401,e.getPermission()); |
| | | } |
| | | |
| | | // 拦截:未登录异常 |