From 84390b67133db7708a21f84b509af5395bfd9ea6 Mon Sep 17 00:00:00 2001 From: Henning Dieterichs Date: Sun, 29 Mar 2020 15:07:38 +0200 Subject: [PATCH] Catches visualization errors. --- webview/src/components/Visualizer.tsx | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/webview/src/components/Visualizer.tsx b/webview/src/components/Visualizer.tsx index 876d897..2507f01 100644 --- a/webview/src/components/Visualizer.tsx +++ b/webview/src/components/Visualizer.tsx @@ -12,6 +12,11 @@ export class Visualizer extends React.Component<{ model: Model }> { ); } + componentDidCatch() { + this.props.model.setVisualizationError({ kind: {} }); + console.log("broken"); + } + renderContent(): JSX.Element { const s = this.props.model.state; if (s.kind === "loading") { @@ -24,6 +29,8 @@ export class Visualizer extends React.Component<{ model: Model }> { ); } else if (s.kind === "noExpression") { return No Expression Entered; + } else if (s.kind === "visualizationError") { + return Visualization Error; } else if (s.kind === "noDebugSession") { return No Active Debug Session; } else if (s.kind === "data") { @@ -32,7 +39,19 @@ export class Visualizer extends React.Component<{ model: Model }> { return No Visualization Available; } - return vis.visualization.render(); + try { + return vis.visualization.render(); + } catch (e) { + console.error(e); + return ( + + <> + Visualization Error +
{e.message}
+ +
+ ); + } } else { const nvr: never = s; return
;