List of usage examples for twitter4j TwitterException resourceNotFound
public boolean resourceNotFound()
From source file:aic2013.follower.TwitterDataAccess.java
public void forAllFriendIds(TwitterUser twitterUser, Processor<Long> processor) { long nextCursor = -1; IDs usersResponse = null;/*w ww. j av a 2s . c o m*/ do { assert usersResponse == null; while (usersResponse == null) { if (!open) { throw new ClosedException(); } try { usersResponse = twitter.getFriendsIDs(twitterUser.getId(), nextCursor); } catch (TwitterException ex) { if (ex.exceededRateLimitation()) { waitForReset(ex.getRateLimitStatus().getSecondsUntilReset() * 1000); } else if (ex.resourceNotFound()) { // throw new RuntimeException("The user for which the friends were requested does not exist any more.", ex); return; } // Retry when other errors like IO-related ones occur } } assert usersResponse != null; nextCursor = usersResponse.getNextCursor(); for (long userId : usersResponse.getIDs()) { processor.process(userId); } usersResponse = null; } while (nextCursor > 0); }
From source file:com.revolucion.secretwit.twitter.TwitterClient.java
License:Open Source License
private String findExceptionCause(TwitterException exception) { if (exception.exceededRateLimitation()) return "Rate limitation exceeded."; if (exception.isCausedByNetworkIssue()) return "Network issue."; if (exception.resourceNotFound()) return "Resource not found."; return exception.getMessage() + " " + exception.getExceptionCode(); }
From source file:TwitterDownload.TwitterHandler.java
public List<Status> getUserTimeline(String searchPhrase, int pageSize) throws TwitterException { String userName = searchPhrase; if (!userName.contains(" ")) { if (!userName.startsWith("@")) return getSearchTweets(userName, pageSize); long lastID = Long.MAX_VALUE; ArrayList<Status> tweets = new ArrayList<Status>(); int count = 200; try {//ww w . j a va 2 s .c o m int i = 0; while (tweets.size() < pageSize) { i++; if (pageSize - tweets.size() > 200) count = 200; else count = pageSize - tweets.size(); Paging page = new Paging(i, count); //page.maxId(lastID); List<Status> l = twitter.getUserTimeline(userName, page); tweets.addAll(l); if (l.size() < 200) { break; } for (Status t : tweets) { if (t.getId() < lastID) lastID = t.getId(); else if (t.getId() == lastID) break; } } return (List<Status>) tweets; } catch (TwitterException ex) { String s = ex.toString(); //TODO: needs to be refined to only include user not found exception if (ex.resourceNotFound()) return getSearchTweets(searchPhrase, pageSize); } catch (Exception ex) { String s = ex.toString(); return null; } } //else return getSearchTweets(userName, pageSize); }