-
-
Notifications
You must be signed in to change notification settings - Fork 540
Fix exception causes in server.py #776
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
Conversation
Looks like the mypy error in the CI is unrelated to my change. |
|
The mypy behavior changes are a constant source of happiness. In this case:
|
Coming back to the original issue, I'm in favor of making changes wherever websockets changes the type of an exception. We should choose between |
Regarding the mypy issue: I'll rebase and see what happens. Regarding In this case, I would have wanted to see the Another issue is that some error-reporting systems show not only the traceback, but all the local variables on each of these levels. These supposedly irrelevant levels could have variables that make it clearer what this exception is about. My policy is to never add |
I fixed the mypy failures in master just now. |
Style detail: I'd rather use Happy to look at a patch fixing other instances besides this one :-) |
Fixed and rebased. Would you be okay with the other instances being fixed in a separate PR after this one is merged? |
Codecov Report
@@ Coverage Diff @@
## master #776 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 31 29 -2
Lines 4433 4388 -45
Branches 409 406 -3
=========================================
- Hits 4433 4388 -45
Continue to review full report at Codecov.
|
Cool :) Expect another PR soon. |
I recently went over Matplotlib, Pandas and NumPy, fixing a small mistake in the way that Python 3's exception chaining is used. If you're interested, I can do it here too. I've done it on just one file right now.
The mistake is this: In some parts of the code, an exception is being caught and replaced with a more user-friendly error. In these cases the syntax
raise new_error from old_error
needs to be used.Python 3's exception chaining means it shows not only the traceback of the current exception, but that of the original exception (and possibly more.) This is regardless of
raise from
. The usage ofraise from
tells Python to put a more accurate message between the tracebacks. Instead of this:You'll get this:
The first is inaccurate, because it signifies a bug in the exception-handling code itself, which is a separate situation than wrapping an exception.
Let me know what you think!