Merge branch 'krille/catch-sync-errors' into 'master'
Catch sync errors See merge request famedly/famedlysdk!332
This commit is contained in:
commit
fbc2a6b1a2
|
@ -647,6 +647,9 @@ class Client {
|
||||||
final StreamController<MatrixException> onError =
|
final StreamController<MatrixException> onError =
|
||||||
StreamController.broadcast();
|
StreamController.broadcast();
|
||||||
|
|
||||||
|
/// Synchronization erros are coming here.
|
||||||
|
final StreamController<SyncError> onSyncError = StreamController.broadcast();
|
||||||
|
|
||||||
/// Synchronization erros are coming here.
|
/// Synchronization erros are coming here.
|
||||||
final StreamController<ToDeviceEventDecryptionError> onOlmError =
|
final StreamController<ToDeviceEventDecryptionError> onOlmError =
|
||||||
StreamController.broadcast();
|
StreamController.broadcast();
|
||||||
|
@ -1034,8 +1037,11 @@ class Client {
|
||||||
} on MatrixException catch (exception) {
|
} on MatrixException catch (exception) {
|
||||||
onError.add(exception);
|
onError.add(exception);
|
||||||
await Future.delayed(Duration(seconds: syncErrorTimeoutSec), _sync);
|
await Future.delayed(Duration(seconds: syncErrorTimeoutSec), _sync);
|
||||||
} catch (exception) {
|
} catch (e, s) {
|
||||||
print('Error during processing events: ' + exception.toString());
|
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);
|
await Future.delayed(Duration(seconds: syncErrorTimeoutSec), _sync);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1158,7 +1164,7 @@ class Client {
|
||||||
print(s);
|
print(s);
|
||||||
onOlmError.add(
|
onOlmError.add(
|
||||||
ToDeviceEventDecryptionError(
|
ToDeviceEventDecryptionError(
|
||||||
exception: e,
|
exception: e is Exception ? e : Exception(e),
|
||||||
stackTrace: s,
|
stackTrace: s,
|
||||||
toDeviceEvent: toDeviceEvent,
|
toDeviceEvent: toDeviceEvent,
|
||||||
),
|
),
|
||||||
|
@ -2191,3 +2197,9 @@ class Client {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class SyncError {
|
||||||
|
Exception exception;
|
||||||
|
StackTrace stackTrace;
|
||||||
|
SyncError({this.exception, this.stackTrace});
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue