From c296afc4a237b1e1ddf45ffc27520346005dcb20 Mon Sep 17 00:00:00 2001 From: "Amy J. Ko" Date: Thu, 4 Jul 2024 14:42:29 -0700 Subject: [PATCH] Show error if there's an exception. --- src/lib/MarkupView.svelte | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/lib/MarkupView.svelte b/src/lib/MarkupView.svelte index ae5121b..e0aff07 100644 --- a/src/lib/MarkupView.svelte +++ b/src/lib/MarkupView.svelte @@ -39,12 +39,18 @@ async function save() { if (edit) { saving = true; - const error = await edit(revisedText); - if (error) { - addError(errors, 'Unable to save markup.', error); - } else { - markup = revisedText; + try { + const error = await edit(revisedText); + if (error) { + addError(errors, 'Unable to save markup.', error); + } else { + markup = revisedText; + editing = false; + } + } catch (err) { editing = false; + addError(errors, '' + err); + saving = false; } saving = false; } else markup = revisedText;