Show error and diagnostics when st.plotly_chart fails instead of silent pass

Previously the st.plotly_chart call was wrapped in 'except Exception: pass'
which silently swallowed all rendering errors. The user would see no chart
and no error message.

Now:
- Exception message is shown via st.error()
- Diagnostics JSON is shown when debug is enabled (EXPLORER_DEBUG_TRAJECTORIES=1
  or UI checkbox), even when trace_count > 0

This reveals the actual root cause when the chart fails to render.
main
Sven Geboers 1 month ago
parent baee50f3a5
commit 72d1c20340
  1. 14
      explorer.py

@ -2096,8 +2096,18 @@ def choose_trajectory_title(axis_def: dict, axis: str, threshold: float = 0.65)
else:
try:
st.plotly_chart(fig, use_container_width=True)
except Exception:
pass
except Exception as e:
st.error(f"Trajectories rendering failed: {e}")
# Always show diagnostics when rendering fails, regardless of trace_count
if get_debug_trajectories_enabled():
try:
st.json(_last_trajectories_diagnostics)
except Exception:
st.text_area(
"Trajectories diagnostics (JSON failed)",
json.dumps(_last_trajectories_diagnostics, default=str),
height=240,
)
# ---------------------------------------------------------------------------

Loading…
Cancel
Save