Ejemplo n.º 1
0
 @Override
 public void onException(URLConnection connection, IOException e) {
   URL url = entry.url;
   if (connection instanceof HttpURLConnection) {
     int responseCode;
     try {
       responseCode = ((HttpURLConnection) connection).getResponseCode();
       if (responseCode >= 400 && responseCode < 500) { // CS-IGNORE
         // url is not local cache
         cachedImages.put(entry.getImageUrl(), new ErrorImageEntry(url, e));
         if (responseCode == HttpURLConnection.HTTP_NOT_FOUND) {
           logger.warn("not found: url={}", url);
         } else {
           logger.warn("Error while fetching: url={}, statusCode={}", url, responseCode, e);
         }
       } else {
         logger.warn("Error while fetching: url={}, statusCode={}", url, responseCode, e);
       }
     } catch (IOException responseCodeException) {
       logger.warn("Cannot retrieve http status code", responseCodeException);
     }
   } else {
     logger.warn("Error while fetching: {}", url, e);
   }
   if (entry.getAlternateEntry() != null) {
     entry = entry.getAlternateEntry();
     configuration.addJob(this);
   }
 }