Merge branch 'krille/catch-sync-errors' into 'master'

Catch sync errors

See merge request famedly/famedlysdk!332
This commit is contained in:
Christian Pauly 2020-06-01 18:24:41 +00:00
commit fbc2a6b1a2
1 changed files with 15 additions and 3 deletions

View File

@ -647,6 +647,9 @@ class Client {
final StreamController<MatrixException> onError =
StreamController.broadcast();
/// Synchronization erros are coming here.
final StreamController<SyncError> onSyncError = StreamController.broadcast();
/// Synchronization erros are coming here.
final StreamController<ToDeviceEventDecryptionError> onOlmError =
StreamController.broadcast();
@ -1034,8 +1037,11 @@ class Client {
} on MatrixException catch (exception) {
onError.add(exception);
await Future.delayed(Duration(seconds: syncErrorTimeoutSec), _sync);
} catch (exception) {
print('Error during processing events: ' + exception.toString());
} catch (e, s) {
print('Error during processing events: ' + e.toString());
print(s);
onSyncError.add(SyncError(
exception: e is Exception ? e : Exception(e), stackTrace: s));
await Future.delayed(Duration(seconds: syncErrorTimeoutSec), _sync);
}
}
@ -1158,7 +1164,7 @@ class Client {
print(s);
onOlmError.add(
ToDeviceEventDecryptionError(
exception: e,
exception: e is Exception ? e : Exception(e),
stackTrace: s,
toDeviceEvent: toDeviceEvent,
),
@ -2191,3 +2197,9 @@ class Client {
return;
}
}
class SyncError {
Exception exception;
StackTrace stackTrace;
SyncError({this.exception, this.stackTrace});
}