From 6316b3b78f9fed0ab82986d2589e0801dd233675 Mon Sep 17 00:00:00 2001 From: Romain Vigier Date: Sat, 8 Feb 2020 23:17:25 +0100 Subject: [PATCH] Improve error handling --- src/extension.js | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/extension.js b/src/extension.js index 6f90034..2112617 100644 --- a/src/extension.js +++ b/src/extension.js @@ -41,14 +41,19 @@ class Switcher { } enable() { - this.theme = new Themer(); - this.variants = Variants.guess_from(this.theme.current); - this.theme.listen(this._on_theme_change.bind(this)); + try { + this.theme = new Themer(); + this.variants = Variants.guess_from(this.theme.current); + this.theme.listen(this._on_theme_change.bind(this)); - this.nightlight = new Nightlighter(); - this.nightlight.listen(this._apply_theme_variant.bind(this)); + this.nightlight = new Nightlighter(); + this.nightlight.listen(this._apply_theme_variant.bind(this)); - this._apply_theme_variant(); + this._apply_theme_variant(); + } + catch(e) { + main.notifyError(EXT_NAME, e.message); + } } disable() { @@ -57,10 +62,7 @@ class Switcher { this.theme.stop_listening(); this.nightlight.stop_listening(); } - catch(e) { - const message = _('Errors occured while disabling the extension, try removing it.'); - main.notifyError(EXT_NAME, message); - } + catch(e) {} finally { this.theme = null; @@ -119,7 +121,7 @@ class Nightlighter { this._connect_to_dbus(); } catch(e) { - main.notifyError(EXT_NAME, e); + throw e; } }