Merge pull request #26637 from blaggacao/feat/error-reraise
This commit is contained in:
commit
4c1b858810
1 changed files with 7 additions and 5 deletions
|
|
@ -296,16 +296,18 @@ def get_traceback(with_context=False) -> str:
|
|||
"""Return the traceback of the Exception."""
|
||||
from traceback_with_variables import iter_exc_lines
|
||||
|
||||
exc_type, exc_value, exc_tb = sys.exc_info()
|
||||
|
||||
if not any([exc_type, exc_value, exc_tb]):
|
||||
exc = sys.exception()
|
||||
if not exc:
|
||||
return ""
|
||||
|
||||
if exc.__cause__:
|
||||
exc = exc.__cause__
|
||||
|
||||
if with_context:
|
||||
trace_list = iter_exc_lines(fmt=_get_traceback_sanitizer())
|
||||
trace_list = iter_exc_lines(exc, fmt=_get_traceback_sanitizer())
|
||||
tb = "\n".join(trace_list)
|
||||
else:
|
||||
trace_list = traceback.format_exception(exc_type, exc_value, exc_tb)
|
||||
trace_list = traceback.format_exception(exc)
|
||||
tb = "".join(cstr(t) for t in trace_list)
|
||||
|
||||
bench_path = get_bench_path() + "/"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue