mirror of
https://github.com/ysoftdevs/DependencyCheck.git
synced 2026-03-21 16:49:43 +01:00
improved error messages to resolve issue #176
Former-commit-id: 57d4e59b50aab93124f321004d05239cd9cd5c3d
This commit is contained in:
@@ -80,11 +80,11 @@ public final class Downloader {
|
|||||||
try {
|
try {
|
||||||
org.apache.commons.io.FileUtils.copyFile(file, outputPath);
|
org.apache.commons.io.FileUtils.copyFile(file, outputPath);
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
final String msg = String.format("Download failed, unable to copy '%s'", url.toString());
|
final String msg = String.format("Download failed, unable to copy '%s' to '%s'", url.toString(), outputPath.getAbsolutePath());
|
||||||
throw new DownloadFailedException(msg);
|
throw new DownloadFailedException(msg);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
final String msg = String.format("Download failed, file does not exist '%s'", url.toString());
|
final String msg = String.format("Download failed, file ('%s') does not exist", url.toString());
|
||||||
throw new DownloadFailedException(msg);
|
throw new DownloadFailedException(msg);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -101,7 +101,8 @@ public final class Downloader {
|
|||||||
} finally {
|
} finally {
|
||||||
conn = null;
|
conn = null;
|
||||||
}
|
}
|
||||||
throw new DownloadFailedException("Error downloading file.", ex);
|
final String msg = String.format("Error downloading file %s; unable to connect.", url.toString());
|
||||||
|
throw new DownloadFailedException(msg, ex);
|
||||||
}
|
}
|
||||||
final String encoding = conn.getContentEncoding();
|
final String encoding = conn.getContentEncoding();
|
||||||
|
|
||||||
@@ -122,13 +123,19 @@ public final class Downloader {
|
|||||||
while ((bytesRead = reader.read(buffer)) > 0) {
|
while ((bytesRead = reader.read(buffer)) > 0) {
|
||||||
writer.write(buffer, 0, bytesRead);
|
writer.write(buffer, 0, bytesRead);
|
||||||
}
|
}
|
||||||
|
} catch (IOException ex) {
|
||||||
|
String msg = String.format("Error saving '%s' to file '%s'%nConnection Timeout: %d%nEncoding: %s%n",
|
||||||
|
url.toString(), outputPath.getAbsolutePath(), conn.getConnectTimeout(), encoding);
|
||||||
|
throw new DownloadFailedException(msg, ex);
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
throw new DownloadFailedException("Error saving downloaded file.", ex);
|
String msg = String.format("Unexpected exception saving '%s' to file '%s'%nConnection Timeout: %d%nEncoding: %s%n",
|
||||||
|
url.toString(), outputPath.getAbsolutePath(), conn.getConnectTimeout(), encoding);
|
||||||
|
throw new DownloadFailedException(msg, ex);
|
||||||
} finally {
|
} finally {
|
||||||
if (writer != null) {
|
if (writer != null) {
|
||||||
try {
|
try {
|
||||||
writer.close();
|
writer.close();
|
||||||
} catch (Throwable ex) {
|
} catch (IOException ex) {
|
||||||
LOGGER.log(Level.FINEST,
|
LOGGER.log(Level.FINEST,
|
||||||
"Error closing the writer in Downloader.", ex);
|
"Error closing the writer in Downloader.", ex);
|
||||||
}
|
}
|
||||||
@@ -136,7 +143,7 @@ public final class Downloader {
|
|||||||
if (reader != null) {
|
if (reader != null) {
|
||||||
try {
|
try {
|
||||||
reader.close();
|
reader.close();
|
||||||
} catch (Throwable ex) {
|
} catch (IOException ex) {
|
||||||
LOGGER.log(Level.FINEST,
|
LOGGER.log(Level.FINEST,
|
||||||
"Error closing the reader in Downloader.", ex);
|
"Error closing the reader in Downloader.", ex);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user