Skip to content

Commit

Permalink
common: include filename in error message
Browse files Browse the repository at this point in the history
Motivation:

If there is an IOException when reading the setup file, the corresponding
filename is not included in the message.  This may make diagnosing the
problem harder for the admin.

Modification:

Wrap the IOException to include the filename.

Result:

More useful error messages

Target: master
Requires-notes: yes
Requires-book: no
Request: 2.16
Request: 2.15
Request: 2.14
Request: 2.13
Patch: https://rb.dcache.org/r/9587/
Acked-by: Gerd Behrmann
  • Loading branch information
paulmillar committed Aug 5, 2016
1 parent 7f280f6 commit 818b04b
Showing 1 changed file with 8 additions and 3 deletions.
Expand Up @@ -310,9 +310,14 @@ private void waitForFiles()

private byte[] loadSetup(File file) throws IOException, CommandException
{
byte[] data = readAllBytes(file.toPath());
testSetup(file.toString(), data);
return data;
try {
byte[] data = readAllBytes(file.toPath());
testSetup(file.toString(), data);
return data;
} catch (IOException e) {
throw new IOException("Failed to read " + file + ": " +
e.getMessage(), e);
}
}

private void testSetup(String source, byte[] data)
Expand Down

0 comments on commit 818b04b

Please sign in to comment.