Skip to content

Commit c3cd67f

Browse files
authored
Call tagify() early to intercept AttributeErrors (#941)
1 parent b61452d commit c3cd67f

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

shiny/express/_run.py

+10
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,16 @@ def wrap_express_app(file: Path) -> App:
3939
)
4040

4141
app_ui = run_express(file)
42+
try:
43+
# We tagify here, instead of waiting for the App object to do it when it wraps
44+
# the UI in a HTMLDocument and calls render() on it. This is because
45+
# AttributeErrors can be thrown during the tagification process, and we need to
46+
# catch them here and convert them to a different type of error, because uvicorn
47+
# specifically catches AttributeErrors and prints an error message that is
48+
# misleading for Shiny Express. https://github.com/posit-dev/py-shiny/issues/937
49+
app_ui = run_express(file).tagify()
50+
except AttributeError as e:
51+
raise RuntimeError(e) from e
4252

4353
def express_server(input: Inputs, output: Outputs, session: Session):
4454
try:

0 commit comments

Comments
 (0)