Clarify the error message when a file cannot be opened for reading #1341
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When
s3cmd
cannot open a local file because the user has no permission to read it, it produces the following error message:That message can mean two different things (at least to the user who doesn't see S3-side errors frequently): either the current user has no permission to read the file or the current AWS credentials do not permit its upload to the target bucket. When that happened to me lately, I spent a few minutes trying to figure out what was wrong with my AWS credentials before I realized that
s3cmd
is actually talking about the local file. :)This PR changes the message to make it clear what actually happens:
The
failed to open the file for reading
message is only prepended whenio.open(filename_bytes, mode='rb')
causesOSError
orIOError
, all other messages (special file, etc.) remain unchanged.I took the liberty to change the format of the "Upload of ... is not possible" message to avoid nested parens there. If it's against your error message guidelines, please let me know.