Skip to content

Commit

Permalink
core: add UnknownDeviceException
Browse files Browse the repository at this point in the history
  • Loading branch information
jjanku committed May 6, 2024
1 parent ff1cf77 commit 0bbdba0
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions meesign_core/lib/src/data/support_services.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import 'package:pub_semver/pub_semver.dart';
import '../util/uuid.dart';
import 'network_dispatcher.dart';

class UnknownDeviceException implements Exception {}

class SupportServices {
final NetworkDispatcher _dispatcher;

Expand All @@ -19,8 +21,17 @@ class SupportServices {
return Version.parse(info.version);
}

Future<bool> checkCompatibility([Uuid? did]) async =>
serverVersionConstraint.allows(await getVersion(did));
Future<bool> checkCompatibility([Uuid? did]) async {
try {
return serverVersionConstraint.allows(await getVersion(did));
} on GrpcError catch (e) {
// FIXME: any better solution?
if (e.message == 'Unknown device certificate') {
throw UnknownDeviceException();
}
rethrow;
}
}

Future<void> log(Uuid? did, String message) =>
(did != null ? _dispatcher[did] : _dispatcher.unauth)
Expand Down

0 comments on commit 0bbdba0

Please sign in to comment.