From 6972790053e9c6cb2ec0f619eea1da2f348b8a45 Mon Sep 17 00:00:00 2001 From: dogeystamp Date: Thu, 26 Jan 2023 19:11:31 -0500 Subject: [PATCH] interface.js: add InterfaceElement.handleError() this allows elements to handle errors directly after catching them rather than having a generic error --- scripts/interface.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/interface.js b/scripts/interface.js index 2ecf0d7..6033173 100644 --- a/scripts/interface.js +++ b/scripts/interface.js @@ -413,6 +413,13 @@ class FormElement extends InterfaceElement { this.handle.after(box); this.alerts.push(box); } + handleError(e, extraInfo="") { + if (extraInfo !== "") { + extraInfo = ` (${extraInfo})`; + } + this.alertBox("alert-error", e.message + extraInfo); + console.error(e); + } clearAlerts() { for (const box of this.alerts) { box.remove();