From ee0f7b5806c8e28e3a7dc002e9dde467d1fa2a9b Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Sat, 28 Jul 2018 17:43:52 +0900 Subject: Catch errors on background --- src/background/infrastructures/content-message-listener.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/background/infrastructures/content-message-listener.js b/src/background/infrastructures/content-message-listener.js index 277d108..2fa5f54 100644 --- a/src/background/infrastructures/content-message-listener.js +++ b/src/background/infrastructures/content-message-listener.js @@ -18,14 +18,12 @@ export default class ContentMessageListener { run() { browser.runtime.onMessage.addListener((message, sender) => { - try { - return this.onMessage(message, sender); - } catch (e) { + return this.onMessage(message, sender).catch((e) => { return browser.tabs.sendMessage(sender.tab.id, { type: messages.CONSOLE_SHOW_ERROR, text: e.message, }); - } + }); }); } -- cgit v1.2.3