-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve message if file exists instead of folder #1568
Improve message if file exists instead of folder #1568
Conversation
continue; | ||
} else if (file.exists()) { | ||
throw new IOException( | ||
"a file with the path \'" + relativePath.getPath() + "\' exists"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can include already
in the message, as createNewFile
includes it in error message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking about the word "already" for this message two. But it is wrong here because the user wants to create a folder and not a file. Therefore we cannot say the file is already there.
"could not create a folder with the path \'" + relativePath.getPath() + "\'"); | ||
if (!lastMkdirsCallSuccessful) { | ||
if (file.exists() && file.isDirectory()) { | ||
continue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could avoid the continue
by moving the !file.isDirectory()
back into the enclosing if
and remove the first inner if
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. Fixed.
When TemporaryFolder(String path) or TemporaryFolder(String... paths) is called with a path that matches the path of an existing file then an IOException with a message like "a file with path <path> exists" is thrown.
3e6be76
to
10a863e
Compare
When
TemporaryFolder(String path)
orTemporaryFolder(String... paths)
iscalled with a path that matches the path of an existing file then an
IOException
with a message like "a file with path exists" isthrown.