Skip to content

Commit

Permalink
chore: Added a UI to handle errors without leaking information to end…
Browse files Browse the repository at this point in the history
… user.
  • Loading branch information
osala-eng committed Sep 27, 2023
1 parent 9865157 commit 2f5c0af
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
5 changes: 2 additions & 3 deletions web/index.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
"""Page: Home (no auth required)."""

import streamlit as st
from docq import setup
from st_pages import Page, Section, add_page_title, show_pages
from utils.layout import org_selection_ui, production_layout, public_access
from utils.layout import load_setup_ui, org_selection_ui, production_layout, public_access

setup.init()
load_setup_ui()


production_layout()
Expand Down
12 changes: 12 additions & 0 deletions web/utils/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from st_pages import hide_pages
from streamlit.components.v1 import html
from streamlit.delta_generator import DeltaGenerator
from docq import setup

from .constants import ALLOWED_DOC_EXTS, SessionKeyNameForAuth, SessionKeyNameForChat
from .formatters import format_archived, format_datetime, format_filesize, format_timestamp
Expand Down Expand Up @@ -878,3 +879,14 @@ def org_selection_ui() -> None:
)
if selected:
handle_org_selection_change(selected[0])



def load_setup_ui() -> None:
"""UI to run setup and prevent showing errors to the user."""
try:
setup.init()
except Exception as e:
st.error("Error while setting up the app please refer to logs for more details.")
log.exception("Error while setting up the app: %s", e)
st.stop()

0 comments on commit 2f5c0af

Please sign in to comment.