3025 shaares
1 result
tagged
exception
Handling own exception class
When you raise an exception from within an except block in Python, you have three options:
- If a new/unexpected exception occurs in the code handling the original exception, raise NewException.
- If you want to wrap the original exception(s) (e.g., with a common base exception to reduce complexity for your users), raise NewException from cause.
- If you want to hide the original exception because it is irrelevant for your users, raise NewException from None.