Kaynağa Gözat

Warn when computed vars raise an exception (#1939)

Masen Furer 1 yıl önce
ebeveyn
işleme
1efc61e1c4
1 değiştirilmiş dosya ile 5 ekleme ve 2 silme
  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.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)