From 3856b618e8e96e529f29be71533980bcf40b53cf Mon Sep 17 00:00:00 2001 From: Christian Pauly Date: Tue, 15 Dec 2020 08:24:55 +0100 Subject: [PATCH] refactor: Encryption errors --- lib/encryption/encryption.dart | 12 ++---------- lib/encryption/utils/bootstrap.dart | 4 +++- lib/src/client.dart | 5 ++--- 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/lib/encryption/encryption.dart b/lib/encryption/encryption.dart index 0207b504..d6fd371a 100644 --- a/lib/encryption/encryption.dart +++ b/lib/encryption/encryption.dart @@ -46,13 +46,6 @@ class Encryption { String get fingerprintKey => olmManager.fingerprintKey; String get identityKey => olmManager.identityKey; - /// ToDeviceEventDecryptionError erros are coming here. - final StreamController - onToDeviceEventDecryptionError = StreamController.broadcast(); - - /// All other erros are coming here. - final StreamController 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; diff --git a/lib/encryption/utils/bootstrap.dart b/lib/encryption/utils/bootstrap.dart index 4c454184..a3264f46 100644 --- a/lib/encryption/utils/bootstrap.dart +++ b/lib/encryption/utils/bootstrap.dart @@ -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; diff --git a/lib/src/client.dart b/lib/src/client.dart index 0cfdaeec..e179bdcf 100644 --- a/lib/src/client.dart +++ b/lib/src/client.dart @@ -573,9 +573,8 @@ class Client extends MatrixApi { /// Synchronization erros are coming here. final StreamController onSyncError = StreamController.broadcast(); - /// Synchronization erros are coming here. - @Deprecated('Please use encryption.onToDeviceEventDecryptionError instead') - final StreamController onOlmError = + /// Encryption erros are coming here. + final StreamController onEncryptionError = StreamController.broadcast(); /// This is called once, when the first sync has received.