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

Use raise from to specify exception cause #27917

Closed
Sai-Suraj-27 opened this issue Jan 14, 2024 · 0 comments · Fixed by #27918
Closed

Use raise from to specify exception cause #27917

Sai-Suraj-27 opened this issue Jan 14, 2024 · 0 comments · Fixed by #27918

Comments

@Sai-Suraj-27
Copy link
Contributor

The from keyword sets the __cause__ attribute of the exception, which stores the "cause" of the exception. The availability of an exception "cause" is useful for debugging.

When you raise a new exception after another exception was caught it's likely that the second exception is a friendly re-wrapping of the first exception. In such cases raise from provides a better link between the two tracebacks in the final error.

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 a pull request may close this issue.

1 participant