forked fromsybrenstuvel/python-rsa
- Notifications
You must be signed in to change notification settings - Fork0
Commit1a5b2d1
Fix exception causes all over the codebase
The mistake is this: In some parts of the code, an exception is beingcaught and replaced with a more user-friendly error. In these cases thesyntax `raise new_error from old_error` needs to be used.Python's exception chaining means it shows not only the traceback of thecurrent exception, but that of the original exception (and possiblymore.) This is regardless of `raise from`. The usage of `raise from`tells Python to put a more accurate message between the tracebacks.Instead of this: During handling of the above exception, another exception occurred:You'll get this: The above exception was the direct cause of the following exception:The first is inaccurate, because it signifies a bug in theexception-handling code itself, which is a separate situation thanwrapping an exception.1 parentb8ac79f commit1a5b2d1
3 files changed
+9
-9
lines changedLines changed: 4 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
58 | 58 |
| |
59 | 59 |
| |
60 | 60 |
| |
61 |
| - | |
| 61 | + | |
62 | 62 |
| |
63 | 63 |
| |
64 |
| - | |
| 64 | + | |
65 | 65 |
| |
66 | 66 |
| |
67 | 67 |
| |
| |||
280 | 280 |
| |
281 | 281 |
| |
282 | 282 |
| |
283 |
| - | |
284 |
| - | |
| 283 | + | |
| 284 | + | |
285 | 285 |
| |
286 | 286 |
| |
287 | 287 |
| |
|
Lines changed: 3 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
131 | 131 |
| |
132 | 132 |
| |
133 | 133 |
| |
134 |
| - | |
| 134 | + | |
135 | 135 |
| |
136 | 136 |
| |
137 |
| - | |
| 137 | + | |
138 | 138 |
| |
139 | 139 |
| |
140 | 140 |
| |
| |||
703 | 703 |
| |
704 | 704 |
| |
705 | 705 |
| |
706 |
| - | |
| 706 | + | |
707 | 707 |
| |
708 | 708 |
| |
709 | 709 |
| |
|
Lines changed: 2 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
49 | 49 |
| |
50 | 50 |
| |
51 | 51 |
| |
52 |
| - | |
| 52 | + | |
53 | 53 |
| |
54 | 54 |
| |
55 | 55 |
| |
56 | 56 |
| |
57 |
| - | |
| 57 | + | |
58 | 58 |
| |
59 | 59 |
| |
60 | 60 |
| |
|
0 commit comments
Comments
(0)