Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1""" 

2@brief 

3@file Various function to help investigate an error. 

4""" 

5import traceback 

6from io import StringIO 

7 

8 

9class ErrorOnPurpose(Exception): 

10 """ 

11 raise to get the call stack 

12 """ 

13 pass 

14 

15 

16def get_call_stack(): 

17 """ 

18 Returns a string showing the call stack 

19 when this function is called. 

20 

21 .. exref:: 

22 :title: Display the call stack 

23 

24 .. runpython:: 

25 :showcode: 

26 

27 from pyquickhelper.pycode import get_call_stack 

28 print(get_call_stack()) 

29 """ 

30 s = StringIO() 

31 traceback.print_stack(file=s) 

32 return s.getvalue()