MCPcopy
hub / github.com/plotly/dash / _get_traceback

Method _get_traceback

tests/backend_tests/test_custom_backend.py:13–77  ·  view source on GitHub ↗
(self, _secret, error: Exception)

Source from the content-addressed store, hash-verified

11
12class CustomDashServer(FastAPIDashServer):
13 def _get_traceback(self, _secret, error: Exception):
14 tb = error.__traceback__
15 errors = traceback.format_exception(type(error), error, tb)
16 pass_errs = []
17 callback_handled = False
18 for err in errors:
19 if self.error_handling_mode == "prune":
20 if not callback_handled:
21 if "callback invoked" in str(err) and "_callback.py" in str(err):
22 callback_handled = True
23 continue
24 pass_errs.append(err)
25 formatted_tb = "".join(pass_errs)
26 error_type = type(error).__name__
27 error_msg = str(error)
28 # Parse traceback lines to group by file
29 file_cards = []
30 pattern = re.compile(r' File "(.+)", line (\d+), in (\w+)')
31 lines = formatted_tb.split("\n")
32 current_file = None
33 card_lines = []
34 for line in lines[:-1]: # Skip the last line (error message)
35 match = pattern.match(line)
36 if match:
37 if current_file and card_lines:
38 file_cards.append((current_file, card_lines))
39 current_file = (
40 f"{match.group(1)} (line {match.group(2)}, in {match.group(3)})"
41 )
42 card_lines = [line]
43 elif current_file:
44 card_lines.append(line)
45 if current_file and card_lines:
46 file_cards.append((current_file, card_lines))
47 cards_html = ""
48 for filename, card in file_cards:
49 cards_html += (
50 f"""
51 <div class=\"error-card\">
52 <div class=\"error-card-header\">{filename}</div>
53 <pre class=\"error-card-traceback\">"""
54 + "\n".join(card)
55 + """</pre>
56 </div>
57 """
58 )
59 html = f"""
60 <!doctype html>
61 <html lang=\"en\">
62 <head>
63 <title>{error_type}: {error_msg} // Custom Debugger</title>
64 <style>
65 body {{ font-family: monospace; background: #fff; color: #333; }}
66 .debugger {{ margin: 2em; max-width: 700px; }}
67 </style>
68 </head>
69 <body>
70 <div class=\"debugger\">

Callers

nothing calls this directly

Calls 4

compileMethod · 0.80
appendMethod · 0.45
matchMethod · 0.45
groupMethod · 0.45

Tested by

no test coverage detected