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 fingerprintKey => olmManager.fingerprintKey;
String get identityKey => olmManager.identityKey; 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; KeyManager keyManager;
OlmManager olmManager; OlmManager olmManager;
KeyVerificationManager keyVerificationManager; KeyVerificationManager keyVerificationManager;
@ -145,11 +138,10 @@ class Encryption {
Logs.error( Logs.error(
'[LibOlm] Could not decrypt to device event from ${event.sender} with content: ${event.content}\n${e.toString()}', '[LibOlm] Could not decrypt to device event from ${event.sender} with content: ${event.content}\n${e.toString()}',
s); s);
onToDeviceEventDecryptionError.add( client.onEncryptionError.add(
ToDeviceEventDecryptionError( SdkError(
exception: e is Exception ? e : Exception(e), exception: e is Exception ? e : Exception(e),
stackTrace: s, stackTrace: s,
toDeviceEvent: event,
), ),
); );
return event; return event;

View File

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

View File

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