Source code for pyquickhelper.pycode.trace_execution
"""
Various function to help investigate an error.
:githublink:`%|py|5`
"""
import traceback
from io import StringIO
[docs]class ErrorOnPurpose(Exception):
"""
raise to get the call stack
:githublink:`%|py|12`
"""
pass
[docs]def get_call_stack():
"""
returns a string showing the call stack
when this function is called
:return: string
:githublink:`%|py|22`
"""
s = StringIO()
traceback.print_stack(file=s)
return s.getvalue()