-
Notifications
You must be signed in to change notification settings - Fork 705
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix formatting of notes possible added to an Exception
- Loading branch information
Showing
5 changed files
with
174 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
|
||
Traceback (most recent call last): | ||
File "tests/exceptions/source/modern/notes.py", line 13, in <module> | ||
raise e | ||
ValueError: invalid value | ||
Note | ||
|
||
[33m[1mTraceback (most recent call last):[0m | ||
|
||
> File "[32mtests/exceptions/source/modern/[0m[32m[1mnotes.py[0m", line [33m13[0m, in [35m<module>[0m | ||
[35m[1mraise[0m [1me[0m | ||
[36m └ [0m[36m[1mValueError('invalid value')[0m | ||
|
||
[31m[1mValueError[0m:[1m invalid value[0m | ||
Note | ||
|
||
Traceback (most recent call last): | ||
File "tests/exceptions/source/modern/notes.py", line 20, in <module> | ||
raise e | ||
ValueError: invalid value | ||
Note1 | ||
Note2 | ||
Note3 | ||
|
||
|
||
[33m[1mTraceback (most recent call last):[0m | ||
|
||
> File "[32mtests/exceptions/source/modern/[0m[32m[1mnotes.py[0m", line [33m20[0m, in [35m<module>[0m | ||
[35m[1mraise[0m [1me[0m | ||
[36m └ [0m[36m[1mValueError('invalid value')[0m | ||
|
||
[31m[1mValueError[0m:[1m invalid value[0m | ||
Note1 | ||
Note2 | ||
Note3 | ||
|
||
|
||
+ Exception Group Traceback (most recent call last): | ||
| File "tests/exceptions/source/modern/notes.py", line 27, in <module> | ||
| raise e | ||
| ExceptionGroup: Grouped (2 sub-exceptions) | ||
| Note 1 | ||
| Note 2 | ||
| Note 3 | ||
+-+---------------- 1 ---------------- | ||
| ValueError: 1 | ||
+---------------- 2 ---------------- | ||
| ValueError: 2 | ||
+------------------------------------ | ||
|
||
+ [33m[1mException Group Traceback (most recent call last):[0m | ||
| | ||
| > File "[32mtests/exceptions/source/modern/[0m[32m[1mnotes.py[0m", line [33m27[0m, in [35m<module>[0m | ||
| [35m[1mraise[0m [1me[0m | ||
| [36m └ [0m[36m[1mExceptionGroup('Grouped', [ValueError(1), ValueError(2)])[0m | ||
| | ||
| [31m[1mExceptionGroup[0m:[1m Grouped (2 sub-exceptions)[0m | ||
| Note 1 | ||
| Note 2 | ||
| Note 3 | ||
+-+---------------- 1 ---------------- | ||
| [31m[1mValueError[0m:[1m 1[0m | ||
+---------------- 2 ---------------- | ||
| [31m[1mValueError[0m:[1m 2[0m | ||
+------------------------------------ | ||
|
||
Traceback (most recent call last): | ||
File "tests/exceptions/source/modern/notes.py", line 32, in <module> | ||
raise e | ||
TabError: tab error | ||
Note | ||
|
||
[33m[1mTraceback (most recent call last):[0m | ||
|
||
> File "[32mtests/exceptions/source/modern/[0m[32m[1mnotes.py[0m", line [33m32[0m, in [35m<module>[0m | ||
[35m[1mraise[0m [1me[0m | ||
[36m └ [0m[36m[1mTabError('tab error')[0m | ||
|
||
[31m[1mTabError[0m:[1m tab error[0m | ||
Note | ||
|
||
Traceback (most recent call last): | ||
File "tests/exceptions/source/modern/notes.py", line 38, in <module> | ||
raise e | ||
File "<string>", line 1 | ||
a = 7 * | ||
^ | ||
SyntaxError: syntax error | ||
Note 1 | ||
Note 2 | ||
|
||
[33m[1mTraceback (most recent call last):[0m | ||
|
||
> File "[32mtests/exceptions/source/modern/[0m[32m[1mnotes.py[0m", line [33m38[0m, in [35m<module>[0m | ||
[35m[1mraise[0m [1me[0m | ||
[36m └ [0m[36m[1mSyntaxError('syntax error', ('<string>', 1, 8, 'a = 7 *\n', 1, 8))[0m | ||
|
||
File "<string>", line 1 | ||
a = 7 * | ||
^ | ||
|
||
[31m[1mSyntaxError[0m:[1m syntax error[0m | ||
Note 1 | ||
Note 2 | ||
|
||
Traceback (most recent call last): | ||
File "tests/exceptions/source/modern/notes.py", line 43, in <module> | ||
raise e | ||
TypeError: type error | ||
|
||
[33m[1mTraceback (most recent call last):[0m | ||
|
||
> File "[32mtests/exceptions/source/modern/[0m[32m[1mnotes.py[0m", line [33m43[0m, in [35m<module>[0m | ||
[35m[1mraise[0m [1me[0m | ||
[36m └ [0m[36m[1mTypeError('type error')[0m | ||
|
||
[31m[1mTypeError[0m:[1m type error[0m |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
from loguru import logger | ||
import sys | ||
|
||
|
||
logger.remove() | ||
logger.add(sys.stderr, format="", diagnose=False, backtrace=False, colorize=False) | ||
logger.add(sys.stderr, format="", diagnose=True, backtrace=True, colorize=True) | ||
|
||
|
||
with logger.catch(): | ||
e = ValueError("invalid value") | ||
e.add_note("Note") | ||
raise e | ||
|
||
|
||
with logger.catch(): | ||
e = ValueError("invalid value") | ||
e.add_note("Note1") | ||
e.add_note("Note2\nNote3\n") | ||
raise e | ||
|
||
|
||
with logger.catch(): | ||
e = ExceptionGroup("Grouped", [ValueError(1), ValueError(2)]) | ||
e.add_note("Note 1\nNote 2") | ||
e.add_note("Note 3") | ||
raise e | ||
|
||
with logger.catch(): | ||
e = TabError("tab error") | ||
e.add_note("Note") | ||
raise e | ||
|
||
with logger.catch(): | ||
e = SyntaxError("syntax error", ("<string>", 1, 8, "a = 7 *\n", 1, 8)) | ||
e.add_note("Note 1") | ||
e.add_note("Note 2") | ||
raise e | ||
|
||
with logger.catch(): | ||
e = TypeError("type error") | ||
e.__notes__ = None | ||
raise e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters