Skip to content
Permalink
Browse files
Improve exception message about check file
Fix #15

Change-Id: Id90b08508a2f43508f7099650795f0b844e317e2
  • Loading branch information
Linary authored and javeme committed Nov 23, 2018
1 parent 0fbea69 commit 6db739029c0dbb70f5210b608ca1c7d37636b36d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
@@ -139,8 +139,8 @@ public void validate(String name, String value) {
File file = new File(value);
if (!file.exists() || !file.isDirectory()) {
throw new ParameterException(String.format(
"Ensure the directory '%s' exists and is indeed a " +
"directory instead of a file", value));
"Ensure the directory exists and is indeed a " +
"directory instead of a file: '%s'", value));
}
}
}
@@ -152,8 +152,8 @@ public void validate(String name, String value) {
File file = new File(value);
if (!file.exists() || !file.isFile()) {
throw new ParameterException(String.format(
"Ensure the file '%s' exists and is indeed a file " +
"instead of a directory", value));
"Ensure the file exists and is indeed a file " +
"instead of a directory: '%s'", value));
}
}
}
@@ -123,14 +123,15 @@ private BufferedReader open(FileSource source) throws IOException {

private static void checkFile(File file) {
if (!file.exists()) {
throw new LoadException("The file %s doesn't exist", file);
throw new LoadException("Please ensure the file exist: '%s'", file);
}
if (!file.isFile()) {
throw new LoadException(
"The file %s must be file rather than a directory", file);
throw new LoadException("Please ensure the file is indeed a file " +
"instead of a directory: '%s'", file);
}
if (!file.canRead()) {
throw new LoadException("The file %s must be readable", file);
throw new LoadException("Please ensure the file is readable: '%s'",
file);
}
}
}

0 comments on commit 6db7390

Please sign in to comment.