Skip to content

Commit 4f27d88

Browse files
committed
added debug option for error handling in terminal for visulisation part
1 parent 8982579 commit 4f27d88

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

mesa/visualization/solara_viz.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import inspect
2828
import threading
2929
import time
30+
import traceback
3031
from collections.abc import Callable
3132
from typing import TYPE_CHECKING, Literal
3233

@@ -273,7 +274,9 @@ def step():
273274
if use_threads.value:
274275
visualization_pause_event.set()
275276
except Exception as e:
276-
print(f"Error in step: {e}")
277+
debug = input(f"Error in step: {e}. Press 'e' for full traceback ")
278+
if debug == "e":
279+
traceback.print_exc()
277280
return
278281

279282
def visualization_task():
@@ -284,7 +287,11 @@ def visualization_task():
284287
visualization_pause_event.clear()
285288
force_update()
286289
except Exception as e:
287-
print(f"Error in visualization_task: {e}")
290+
debug = print(
291+
f"Error in visualization_task: {e}. Press 'e' for full traceback "
292+
)
293+
if debug == "e":
294+
traceback.print_exc()
288295

289296
solara.lab.use_task(
290297
step, dependencies=[playing.value, running.value], prefer_threaded=True

0 commit comments

Comments
 (0)