Merge branch 'krille/add-olm-error-stream' into 'master'

Add olm error stream

See merge request famedly/famedlysdk!323
This commit is contained in:
Christian Pauly 2020-05-22 13:57:19 +00:00
commit b78315872f
2 changed files with 29 additions and 4 deletions

View File

@ -639,6 +639,10 @@ class Client {
final StreamController<MatrixException> onError =
StreamController.broadcast();
/// Synchronization erros are coming here.
final StreamController<ToDeviceEventDecryptionError> onOlmError =
StreamController.broadcast();
/// This is called once, when the first sync has received.
final StreamController<bool> onFirstSync = StreamController.broadcast();
@ -1134,11 +1138,18 @@ class Client {
if (toDeviceEvent.type == 'm.room.encrypted') {
try {
toDeviceEvent = decryptToDeviceEvent(toDeviceEvent);
} catch (e) {
} catch (e, s) {
print(
'[LibOlm] Could not decrypt to device event from ${toDeviceEvent.sender}: ' +
e.toString());
print(toDeviceEvent.sender);
'[LibOlm] Could not decrypt to device event from ${toDeviceEvent.sender} with content: ${toDeviceEvent.content}');
print(e);
print(s);
onOlmError.add(
ToDeviceEventDecryptionError(
exception: e,
stackTrace: s,
toDeviceEvent: toDeviceEvent,
),
);
toDeviceEvent = ToDeviceEvent.fromJson(events[i]);
}
}

View File

@ -24,3 +24,17 @@ class ToDeviceEvent {
return data;
}
}
class ToDeviceEventDecryptionError extends ToDeviceEvent {
Exception exception;
StackTrace stackTrace;
ToDeviceEventDecryptionError({
ToDeviceEvent toDeviceEvent,
this.exception,
this.stackTrace,
}) : super(
sender: toDeviceEvent.sender,
content: toDeviceEvent.content,
type: toDeviceEvent.type,
);
}