More nicely handle errors in setting up dbus/network manager listeners
continuous-integration/drone/pr Build is pending Details

This commit is contained in:
Sarah Jamie Lewis 2023-09-11 11:15:17 -07:00
parent 05b1616473
commit 29bdd2af02
2 changed files with 13 additions and 8 deletions

View File

@ -50,13 +50,18 @@ class ConnectivityPlusLinuxPlugin extends ConnectivityPlatform {
Future<void> _startListenConnectivity() async {
_client ??= createClient();
await _client!.connect();
_addConnectivity(_client!);
_client!.propertiesChanged.listen((properties) {
if (properties.contains('Connectivity')) {
_addConnectivity(_client!);
}
});
try {
await _client!.connect();
_addConnectivity(_client!);
_client!.propertiesChanged.listen((properties) {
if (properties.contains('Connectivity')) {
_addConnectivity(_client!);
}
});
} catch (e) {
// This will just cause connectivity manager to not have any listenable sources, this should not impact core functionality.
print("Dbus or NetworkManager support is unavailable. Cwtch will be unable to efficiently respond to changes in Networking State, however core functionality will be unimpacted.");
}
}
void _addConnectivity(NetworkManagerClient client) {

View File

@ -296,7 +296,7 @@ class NetworkManagerClient {
// Big old grody Hack
// DBus/nm doesnt seem to offer a way to deter ine if dbus is available on system
// worse the first connections get triggered in dbus_client onListen an isn't a catahable exception so crashes the app
// worse the first connections get triggered in dbus_client onListen an isn't a catchable exception so crashes the app
// this is a hacky way to force an exception on thread if dbus isn't available and bail with out crashing
try {
await _root.client.getNameOwner(_root.name);