From 4f5c0467e158041bd46c6ce71fe8c6e909171d05 Mon Sep 17 00:00:00 2001 From: Ben Jeffery Date: Tue, 29 Aug 2023 18:53:46 +0100 Subject: [PATCH 1/2] Add loading indicator to pages --- app.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app.py b/app.py index a7d72a0..f1537e8 100644 --- a/app.py +++ b/app.py @@ -29,7 +29,9 @@ def show(page): - return pages[page](tsm) + yield pn.indicators.LoadingSpinner(value=True, width=50, height=50) + content = pages[page](tsm) + yield content starting_page = pn.state.session_args.get("page", [b"Overview"])[0].decode() From 9ee487c5a04b4a36acd3196b464335d468a14d5f Mon Sep 17 00:00:00 2001 From: Ben Jeffery Date: Tue, 29 Aug 2023 23:16:26 +0100 Subject: [PATCH 2/2] Add error handling --- app.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/app.py b/app.py index f1537e8..3f170f0 100644 --- a/app.py +++ b/app.py @@ -1,6 +1,7 @@ import logging import pathlib import sys +import traceback import panel as pn import tskit @@ -30,7 +31,17 @@ def show(page): yield pn.indicators.LoadingSpinner(value=True, width=50, height=50) - content = pages[page](tsm) + try: + content = pages[page](tsm) + except Exception as e: + error_message = f"An error occurred: {str(e)}" + error_traceback = traceback.format_exc().replace("\n", "
") + error_traceback = f"
{error_traceback}
" + error_panel = pn.pane.Markdown( + f"## Error\n\n{error_message}\n\n{error_traceback}", style={"color": "red"} + ) + yield error_panel + return yield content