Skip to content

improve UI-facing error handling #327

@jessiclassy

Description

@jessiclassy
  • Create a utils function called render_page which wraps an entire page in a try-except clause
  • Each page's code needs to wrapped in a main() function for this to work
  • Upon an exception, we can log the error to runtime logs but also run a Slack alert

See example snippets to incorporate into the codebase:

def render_page(page_func):
    try:
        page_func()
    except Exception as e:
        logging.error(e)
        send_slack_alert(str(e))
        st.error("Something went wrong loading the data. Please try again later.")
        st.stop()

and

def main():
    # for each page, move all page logic here
    df = load_data()
    st.dataframe(df)

render_page(main)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions