List of usage examples for twitter4j TwitterException isErrorMessageAvailable
public boolean isErrorMessageAvailable()
From source file:org.apache.streams.twitter.provider.TwitterErrorHandler.java
License:Apache License
public static int handleTwitterError(Twitter twitter, Exception exception) { if (exception instanceof TwitterException) { TwitterException e = (TwitterException) exception; if (e.exceededRateLimitation()) { LOGGER.warn("Rate Limit Exceeded"); try { Thread.sleep(retry); } catch (InterruptedException e1) { Thread.currentThread().interrupt(); }// w w w . j a v a2s .co m return 1; } else if (e.isCausedByNetworkIssue()) { LOGGER.info("Twitter Network Issues Detected. Backing off..."); LOGGER.info("{} - {}", e.getExceptionCode(), e.getLocalizedMessage()); try { Thread.sleep(retry); } catch (InterruptedException e1) { Thread.currentThread().interrupt(); } return 1; } else if (e.isErrorMessageAvailable()) { if (e.getMessage().toLowerCase().contains("does not exist")) { LOGGER.warn("User does not exist..."); return 100; } else { return 1; } } else { if (e.getExceptionCode().equals("ced778ef-0c669ac0")) { // This is a known weird issue, not exactly sure the cause, but you'll never be able to get the data. return 5; } else { LOGGER.warn("Unknown Twitter Exception..."); LOGGER.warn(" Account: {}", twitter); LOGGER.warn(" Access: {}", e.getAccessLevel()); LOGGER.warn(" Code: {}", e.getExceptionCode()); LOGGER.warn(" Message: {}", e.getLocalizedMessage()); return 1; } } } else if (exception instanceof RuntimeException) { LOGGER.warn("TwitterGrabber: Unknown Runtime Error", exception.getMessage()); return 1; } else { LOGGER.info("Completely Unknown Exception: {}", exception); return 1; } }