network: Catch errors when reading devices

NetworkManager added support for a new device - NMDeviceWifiP2P - but
did not add the corresponding enum value in NMDeviceType. The return
value for nm_device_get_device_type() is therefore "illegal" for the
newly added device, and gjs throws an exception.

This should ultimately be fixed in libnm, but as errors when adding
one device shouldn't interfere with adding any other devices, catching
exception is a good idea anyway, so do just that.

https://gitlab.gnome.org/GNOME/gnome-shell/issues/1023
This commit is contained in:
Florian Müllner 2019-03-07 20:26:12 +01:00 committed by Marco Trevisan
parent b05683d586
commit 4fa5d701d5

View File

@ -1673,7 +1673,11 @@ var NMApplet = class extends PanelMenu.SystemIndicator {
_readDevices() {
let devices = this._client.get_devices() || [ ];
for (let i = 0; i < devices.length; ++i) {
this._deviceAdded(this._client, devices[i], true);
try {
this._deviceAdded(this._client, devices[i], true);
} catch (e) {
log(`Failed to add device ${devices[i]}: ${e}`);
}
}
this._syncDeviceNames();
}