mirror of https://github.com/Textualize/rich.git
Print cause of exceptions even when they have no traceback
For example, exceptions raised by 'multiprocessing' may not include a traceback. Instead, they include the traceback from another process formatted as a string in the description of the exception. It contains important information, so it should be printed by rich.
This commit is contained in:
parent
aea574a215
commit
0817587669
|
@ -43,6 +43,7 @@ The following people have contributed to the development of Rich:
|
|||
- [Nicolas Simonds](https://github.com/0xDEC0DE)
|
||||
- [Aaron Stephens](https://github.com/aaronst)
|
||||
- [Gabriele N. Tornetta](https://github.com/p403n1x87)
|
||||
- [Nils Vu](https://github.com/nilsvu)
|
||||
- [Arian Mollik Wasi](https://github.com/wasi-master)
|
||||
- [Handhika Yanuar Pratama](https://github.com/theDreamer911)
|
||||
- [za](https://github.com/za)
|
||||
|
|
|
@ -389,19 +389,17 @@ class Traceback:
|
|||
del stack.frames[:]
|
||||
|
||||
cause = getattr(exc_value, "__cause__", None)
|
||||
if cause and cause.__traceback__:
|
||||
if cause:
|
||||
exc_type = cause.__class__
|
||||
exc_value = cause
|
||||
# __traceback__ can be None, e.g. for exceptions raised by the
|
||||
# 'multiprocessing' module
|
||||
traceback = cause.__traceback__
|
||||
is_cause = True
|
||||
continue
|
||||
|
||||
cause = exc_value.__context__
|
||||
if (
|
||||
cause
|
||||
and cause.__traceback__
|
||||
and not getattr(exc_value, "__suppress_context__", False)
|
||||
):
|
||||
if cause and not getattr(exc_value, "__suppress_context__", False):
|
||||
exc_type = cause.__class__
|
||||
exc_value = cause
|
||||
traceback = cause.__traceback__
|
||||
|
|
Loading…
Reference in New Issue