Debian Codegraph @

examples/recursive_error.py

raw
1 """
2
3 Demonstrates Rich tracebacks for recursion errors.
4
5 Rich can exclude frames in the middle to avoid huge tracebacks.
6
7 """
8
9 from rich.console import Console
10
11
12 def foo(n):
13 return bar(n)
14
15
16 def bar(n):
17 return foo(n)
18
19
20 console = Console()
21
22 try:
23 foo(1)
24 except Exception:
25 console.print_exception(max_frames=20)