Improve error handling

This commit is contained in:
Romain Vigier
2020-02-08 23:17:25 +01:00
parent f6ba91e3f1
commit 6316b3b78f
+13 -11
View File
@@ -41,14 +41,19 @@ class Switcher {
} }
enable() { enable() {
this.theme = new Themer(); try {
this.variants = Variants.guess_from(this.theme.current); this.theme = new Themer();
this.theme.listen(this._on_theme_change.bind(this)); this.variants = Variants.guess_from(this.theme.current);
this.theme.listen(this._on_theme_change.bind(this));
this.nightlight = new Nightlighter(); this.nightlight = new Nightlighter();
this.nightlight.listen(this._apply_theme_variant.bind(this)); 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() { disable() {
@@ -57,10 +62,7 @@ class Switcher {
this.theme.stop_listening(); this.theme.stop_listening();
this.nightlight.stop_listening(); this.nightlight.stop_listening();
} }
catch(e) { catch(e) {}
const message = _('Errors occured while disabling the extension, try removing it.');
main.notifyError(EXT_NAME, message);
}
finally finally
{ {
this.theme = null; this.theme = null;
@@ -119,7 +121,7 @@ class Nightlighter {
this._connect_to_dbus(); this._connect_to_dbus();
} }
catch(e) { catch(e) {
main.notifyError(EXT_NAME, e); throw e;
} }
} }