code: private void updateFailure(DownloadRequest request, int statusCode, String errMsg) {
      updateState(request, DownloadState.FAILURE);
  
      /* if the status code is 0, may be cause by the net error */
      int leftRetryTime = request.retryTime();
      if (leftRetryTime >= 0) {
        try {
          /* sleep a while before retrying */
          sleep(request.retryInterval());
        } catch (InterruptedException e) {
          /* we may have been interrupted because it was time to quit */
          if (quit) {
            request.finish();
            return;
          }
        }
  
        /* retry downloading */
        if (!request.isCanceled()) {
          logger.log("Retry DownloadRequest: "
              + request.downloadId()
              + " left retry time: "
              + leftRetryTime);
          updateRetry(request);
          executeDownload(request);
        }
  
        return;
      }
  
      /* notify the request that downloading has finished */
      request.finish();
  
      /* deliver failure message */
      delivery.postFailure(request, statusCode, errMsg);
    }
docs: /* update download failure