Skip to content
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

Fix exception chaining all over the codebase #1943

Closed
4 tasks done
akihironitta opened this issue Aug 22, 2020 · 1 comment
Closed
4 tasks done

Fix exception chaining all over the codebase #1943

akihironitta opened this issue Aug 22, 2020 · 1 comment
Labels
enhancement Improvements or good new features

Comments

@akihironitta
Copy link
Contributor

akihironitta commented Aug 22, 2020

I would like to suggest a small fix in the way that Python 3's exception chaining is used.

As described in this article, exception chaining can be used to make exceptions more user-friendly, and in that case, the syntax raise new_exception from old_exception needs to be used.

For example,

try:
    something_which_raises_TypeError
except TypeError as e:
    raise ValueError("a more user-friendly exception message.") from e

the above should be used instead of

try:
    something_which_raises_TypeError
except TypeError:
    raise ValueError("a more user-friendly exception message.")

The following files (or possibly more) can be modified according to this syntax:

Let me know your thoughts on this!

facebook-github-bot pushed a commit that referenced this issue Aug 25, 2020
Summary:
## Motivation
See #1943.

## Description of the changes
Fixed exception chaining with the syntax `raise new_exception from old_exception` as in #1943.

Pull Request resolved: #1945

Reviewed By: alexander-kirillov

Differential Revision: D23286925

Pulled By: ppwwyyxx

fbshipit-source-id: ff3f8a23f16f1cb49f10dcb3f2089ec3f9e26ee0
@ppwwyyxx
Copy link
Contributor

closed in #1945. thanks for the PR!

@ppwwyyxx ppwwyyxx added the enhancement Improvements or good new features label Aug 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvements or good new features
Projects
None yet
Development

No branches or pull requests

2 participants