summaryrefslogtreecommitdiff
path: root/ext/sb/js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/sb/js')
-rw-r--r--ext/sb/js/sandbox.js13
1 files changed, 11 insertions, 2 deletions
diff --git a/ext/sb/js/sandbox.js b/ext/sb/js/sandbox.js
index 0a0ff31b..c3430afe 100644
--- a/ext/sb/js/sandbox.js
+++ b/ext/sb/js/sandbox.js
@@ -31,7 +31,16 @@ window.addEventListener('message', event => {
window.yomichan_cache[event.data.template] = template;
}
- const result = template(event.data.data || {});
- event.source.postMessage({result, sequence: event.data.sequence}, '*');
+ let result = null;
+ let command = null;
+ try {
+ command = 'render';
+ result = template(event.data.data || {});
+ } catch (e) {
+ command = 'error';
+ result = e;
+ }
+
+ event.source.postMessage({result, command, sequence: event.data.sequence}, '*');
}
});