summaryrefslogtreecommitdiff
path: root/ext/bg
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2017-09-09 11:36:50 -0700
committerAlex Yatskov <alex@foosoft.net>2017-09-09 11:36:50 -0700
commit9a5a9aa47fd9a6c7ea6830a821689321e8fd9fbb (patch)
treeb91dc77ea6498cf60a6d842e55d148e2d9d73256 /ext/bg
parent124ecaf8247af673109085eee8fab8d5f2bc7caa (diff)
better error handling
Diffstat (limited to 'ext/bg')
-rw-r--r--ext/bg/js/api.js7
1 files changed, 6 insertions, 1 deletions
diff --git a/ext/bg/js/api.js b/ext/bg/js/api.js
index 5a307df3..6ab130a7 100644
--- a/ext/bg/js/api.js
+++ b/ext/bg/js/api.js
@@ -104,7 +104,12 @@ async function apiTemplateRender(template, data, dynamic) {
const sequence = utilBackend().sequenceNew();
const handler = event => {
if (event.data.sequence === sequence) {
- resolve(event.data.result);
+ if (event.data.command === 'error') {
+ reject(event.data.result);
+ } else {
+ resolve(event.data.result);
+ }
+
window.removeEventListener('message', handler);
}
};