[jps cache] Add HTTP status code at logging the root cause of failed download

GitOrigin-RevId: 788a96457df1aa1759ff9894c4e610c9c92b1df0
This commit is contained in:
Mikhail Mazurkevich
2021-08-02 11:40:18 +00:00
committed by intellij-monorepo-bot
parent ef43e8f093
commit 5383ca921e
@@ -62,15 +62,23 @@ class JpsCachesDownloader {
try {
downloaded = downloadFile(description, existing, requestHeaders, indicator);
} catch (IOException e) {
if (e instanceof HttpRequests.HttpStatusException && ((HttpRequests.HttpStatusException)e).getStatusCode() == 404) {
LOG.info("File not found to download " + description.getDownloadUrl());
indicator.finished();
return null;
int httpStatusCode = -1;
if (e instanceof HttpRequests.HttpStatusException) {
httpStatusCode = ((HttpRequests.HttpStatusException)e).getStatusCode();
if (httpStatusCode == 404) {
LOG.info("File not found to download " + description.getDownloadUrl());
indicator.finished();
return null;
}
}
// If max attempt count exceeded, rethrow exception further
if (attempt != MAX_RETRY_COUNT) {
LOG.info("Failed to download " + description.getDownloadUrl() + ". Attempt " + attempt + " to download file again");
if (httpStatusCode != -1) {
LOG.info("Failed to download " + description.getDownloadUrl() + " HTTP code: " + httpStatusCode + ". Attempt " + attempt + " to download file again");
} else {
LOG.info("Failed to download " + description.getDownloadUrl() + ". Attempt " + attempt + " to download file again");
}
} else {
throw new IOException(IdeBundle.message("error.file.download.failed", description.getDownloadUrl(), e.getMessage()), e);
}