From 3697c2cc2ca8a3215853c0160907e3a075db7b01 Mon Sep 17 00:00:00 2001 From: Andrew Morris Date: Wed, 14 Dec 2022 10:19:33 +1100 Subject: [PATCH] Show compilation failed --- website/src/playground/index.ts | 8 +++++++- website/src/playground/styles.scss | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/website/src/playground/index.ts b/website/src/playground/index.ts index eeb33a4..62aae7e 100644 --- a/website/src/playground/index.ts +++ b/website/src/playground/index.ts @@ -109,6 +109,12 @@ editorEl.innerHTML = ""; }); function handleUpdate() { - vsmEl.textContent = vslib.compile(model.getValue()); + try { + vsmEl.textContent = vslib.compile(model.getValue()); + vsmEl.classList.remove("error"); + } catch (_error) { + vsmEl.textContent = "Compilation failed"; + vsmEl.classList.add("error"); + } } })(); diff --git a/website/src/playground/styles.scss b/website/src/playground/styles.scss index 02db7dc..556bf56 100644 --- a/website/src/playground/styles.scss +++ b/website/src/playground/styles.scss @@ -208,3 +208,7 @@ input[type=text] { cursor: pointer; user-select: none; } + +#vsm.error { + background-color: hsla(0, 100%, 50%, 0.05); +}