Add error handling
This commit is contained in:
+22
-13
@@ -50,19 +50,28 @@ function enable() {
|
|||||||
user_theme_day = original_user_theme.replace('-dark', '');
|
user_theme_day = original_user_theme.replace('-dark', '');
|
||||||
user_theme_night = user_theme_day + '-dark';
|
user_theme_night = user_theme_day + '-dark';
|
||||||
|
|
||||||
// Get session DBus, listen to Color changes and change theme variant
|
// Connect to session bus, listen to Color changes and change theme variant
|
||||||
conn = Gio.bus_get_sync(Gio.BusType.SESSION, null);
|
try {
|
||||||
if ( conn === null ) return;
|
conn = Gio.bus_get_sync(Gio.BusType.SESSION, null);
|
||||||
proxy = Gio.DBusProxy.new_sync(
|
if ( conn === null ) {
|
||||||
conn,
|
throw new Error('Unable to connect to the session bus');
|
||||||
Gio.DBusProxyFlags.GET_INVALIDATED_PROPERTIES,
|
}
|
||||||
null,
|
proxy = Gio.DBusProxy.new_sync(
|
||||||
'org.gnome.SettingsDaemon.Color',
|
conn,
|
||||||
'/org/gnome/SettingsDaemon/Color',
|
Gio.DBusProxyFlags.GET_INVALIDATED_PROPERTIES,
|
||||||
'org.gnome.SettingsDaemon.Color',
|
null,
|
||||||
null
|
'org.gnome.SettingsDaemon.Color',
|
||||||
);
|
'/org/gnome/SettingsDaemon/Color',
|
||||||
if ( proxy === null ) return;
|
'org.gnome.SettingsDaemon.Color',
|
||||||
|
null
|
||||||
|
);
|
||||||
|
if ( proxy === null ) {
|
||||||
|
throw new Error('Unable to create proxy to the session bus');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(e) {
|
||||||
|
logError(e)
|
||||||
|
}
|
||||||
proxy_connect_id = proxy.connect('g-properties-changed', _apply_theme_variant);
|
proxy_connect_id = proxy.connect('g-properties-changed', _apply_theme_variant);
|
||||||
_apply_theme_variant();
|
_apply_theme_variant();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user