refactor: Encryption errors

This commit is contained in:
Christian Pauly 2020-12-15 08:24:55 +01:00
parent 60af1d0259
commit 3856b618e8
3 changed files with 7 additions and 14 deletions

View File

@ -46,13 +46,6 @@ class Encryption {
String get fingerprintKey => olmManager.fingerprintKey;
String get identityKey => olmManager.identityKey;
/// ToDeviceEventDecryptionError erros are coming here.
final StreamController<ToDeviceEventDecryptionError>
onToDeviceEventDecryptionError = StreamController.broadcast();
/// All other erros are coming here.
final StreamController<SdkError> onError = StreamController.broadcast();
KeyManager keyManager;
OlmManager olmManager;
KeyVerificationManager keyVerificationManager;
@ -145,11 +138,10 @@ class Encryption {
Logs.error(
'[LibOlm] Could not decrypt to device event from ${event.sender} with content: ${event.content}\n${e.toString()}',
s);
onToDeviceEventDecryptionError.add(
ToDeviceEventDecryptionError(
client.onEncryptionError.add(
SdkError(
exception: e is Exception ? e : Exception(e),
stackTrace: s,
toDeviceEvent: event,
),
);
return event;

View File

@ -557,7 +557,9 @@ class Bootstrap {
'[Bootstrapping] Error setting up online key backup: ' + e.toString(),
s);
state = BootstrapState.error;
encryption.onError.add(SdkError(exception: e, stackTrace: s));
encryption.client.onEncryptionError.add(
SdkError(exception: e, stackTrace: s),
);
return;
}
state = BootstrapState.done;

View File

@ -573,9 +573,8 @@ class Client extends MatrixApi {
/// Synchronization erros are coming here.
final StreamController<SdkError> onSyncError = StreamController.broadcast();
/// Synchronization erros are coming here.
@Deprecated('Please use encryption.onToDeviceEventDecryptionError instead')
final StreamController<ToDeviceEventDecryptionError> onOlmError =
/// Encryption erros are coming here.
final StreamController<SdkError> onEncryptionError =
StreamController.broadcast();
/// This is called once, when the first sync has received.