Add olm error stream
This commit is contained in:
parent
09edda1f9f
commit
c01f75bafa
|
@ -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]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue