From 1efc61e1c4e3bc3349aa779f4b834b8bf1140fff Mon Sep 17 00:00:00 2001 From: Masen Furer Date: Tue, 17 Oct 2023 10:41:36 -0700 Subject: [PATCH] Warn when computed vars raise an exception (#1939) --- reflex/compiler/utils.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/reflex/compiler/utils.py b/reflex/compiler/utils.py index 630eb9680..dc7c384a4 100644 --- a/reflex/compiler/utils.py +++ b/reflex/compiler/utils.py @@ -23,7 +23,7 @@ from reflex.components.base import ( from reflex.components.component import Component, ComponentStyle, CustomComponent from reflex.state import Cookie, LocalStorage, State from reflex.style import Style -from reflex.utils import format, imports, path_ops +from reflex.utils import console, format, imports, path_ops from reflex.vars import ImportVar # To re-export this function. @@ -138,7 +138,10 @@ def compile_state(state: Type[State]) -> dict: """ try: initial_state = state().dict() - except Exception: + except Exception as e: + console.warn( + f"Failed to compile initial state with computed vars, excluding them: {e}" + ) initial_state = state().dict(include_computed=False) return format.format_state(initial_state)