Catch sync errors

This commit is contained in:
Christian Pauly 2020-06-01 18:24:41 +00:00
parent b396fc7d71
commit bd00c066c8

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});
}