Skip to content

Prevent recursion on error translation #443

Merged
martindurant merged 3 commits into
fsspec:mainfrom
isidentical:cause-recursion
Mar 17, 2021
Merged

Prevent recursion on error translation #443
martindurant merged 3 commits into
fsspec:mainfrom
isidentical:cause-recursion

Conversation

@isidentical
Copy link
Copy Markdown
Member

Resolves #442

@isidentical isidentical mentioned this pull request Mar 17, 2021
13 tasks
Comment thread s3fs/tests/test_s3fs.py
# Since the error is not translate, the __cause__ would
# be None
with pytest.raises(NoCredentialsError) as exc:
s3.info("test/a.txt")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this case print the "During handling of the above exception, another exception occurred:" message that generally worries users? Perhaps we should set ex.__suppress_context__ = True in every case.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this case print the "During handling of the above exception, another exception occurred:" message that generally worries users?

Though in this case (NoCredentialsFound), the exception won't be in the context of anything will it? Considering that it is the only exception. For the rest (like the ones s3fs translates), setting __cause__ would implicitly set __suppress_context__ true.

@martindurant
Copy link
Copy Markdown
Member

OK, I think this is an improvement. It certainly gives us a single point to improve messaging in the future, should we wish to do so.
Thanks, @isidentical

@martindurant martindurant merged commit 1f719af into fsspec:main Mar 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Exception translation logic creates recursion in some cases

2 participants