From ff0240bedbc78aaea3219b5d1d9827ef7c9bf06e Mon Sep 17 00:00:00 2001 From: guerler Date: Mon, 20 Jan 2025 11:51:06 -0500 Subject: [PATCH] Add basic error handling to vega wrapper --- client/src/components/Common/VegaWrapper.vue | 16 ++++++---- .../components/Markdown/Editor/CellEditor.vue | 8 +++-- .../Markdown/Sections/MarkdownVega.vue | 30 +++++++++++++++---- 3 files changed, 39 insertions(+), 15 deletions(-) diff --git a/client/src/components/Common/VegaWrapper.vue b/client/src/components/Common/VegaWrapper.vue index 8a46fec2fd0a..798a18620d2d 100644 --- a/client/src/components/Common/VegaWrapper.vue +++ b/client/src/components/Common/VegaWrapper.vue @@ -27,12 +27,16 @@ const chartContainer = ref(null); let vegaView: any; async function embedChart() { - if (vegaView) { - vegaView.finalize(); - } - if (chartContainer.value !== null) { - const result = await embed(chartContainer.value, props.spec, { renderer: "svg" }); - vegaView = result.view; + try { + if (vegaView) { + vegaView.finalize(); + } + if (chartContainer.value !== null) { + const result = await embed(chartContainer.value, props.spec, { renderer: "svg" }); + vegaView = result.view; + } + } catch (e: any) { + console.error(String(e)); } } diff --git a/client/src/components/Markdown/Editor/CellEditor.vue b/client/src/components/Markdown/Editor/CellEditor.vue index 2161f5a66ec2..cb3b3c5ea153 100644 --- a/client/src/components/Markdown/Editor/CellEditor.vue +++ b/client/src/components/Markdown/Editor/CellEditor.vue @@ -20,12 +20,14 @@