Skip to content

Commit

Permalink
Merge pull request #71 from benjeffery/progress
Browse files Browse the repository at this point in the history
Add loading indicator and error handling to pages
  • Loading branch information
jeromekelleher authored Aug 30, 2023
2 parents 1b2cb4a + 9ee487c commit 12a46bb
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion app.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import logging
import pathlib
import sys
import traceback

import panel as pn
import tskit
Expand Down Expand Up @@ -29,7 +30,19 @@


def show(page):
return pages[page](tsm)
yield pn.indicators.LoadingSpinner(value=True, width=50, height=50)
try:
content = pages[page](tsm)
except Exception as e:
error_message = f"An error occurred: {str(e)}"
error_traceback = traceback.format_exc().replace("\n", "<br>")
error_traceback = f"<pre>{error_traceback}</pre>"
error_panel = pn.pane.Markdown(
f"## Error\n\n{error_message}\n\n{error_traceback}", style={"color": "red"}
)
yield error_panel
return
yield content


starting_page = pn.state.session_args.get("page", [b"Overview"])[0].decode()
Expand Down

0 comments on commit 12a46bb

Please sign in to comment.