Răsfoiți Sursa

Warn when computed vars raise an exception (#1939)

Masen Furer 1 an în urmă
părinte
comite
1efc61e1c4
1 a modificat fișierele cu 5 adăugiri și 2 ștergeri
  1. 5 2
      reflex/compiler/utils.py

+ 5 - 2
reflex/compiler/utils.py

@@ -23,7 +23,7 @@ from reflex.components.base import (
 from reflex.components.component import Component, ComponentStyle, CustomComponent
 from reflex.components.component import Component, ComponentStyle, CustomComponent
 from reflex.state import Cookie, LocalStorage, State
 from reflex.state import Cookie, LocalStorage, State
 from reflex.style import Style
 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
 from reflex.vars import ImportVar
 
 
 # To re-export this function.
 # To re-export this function.
@@ -138,7 +138,10 @@ def compile_state(state: Type[State]) -> dict:
     """
     """
     try:
     try:
         initial_state = state().dict()
         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)
         initial_state = state().dict(include_computed=False)
     return format.format_state(initial_state)
     return format.format_state(initial_state)