From 9fac03639e306becfa3fa17c663d79aed922818f Mon Sep 17 00:00:00 2001 From: Christian Pauly Date: Wed, 3 Feb 2021 11:01:01 +0100 Subject: [PATCH] change: Olm exception handling --- lib/encryption/encryption.dart | 3 ++- lib/encryption/olm_manager.dart | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/encryption/encryption.dart b/lib/encryption/encryption.dart index 65992f3f..4a75f1dd 100644 --- a/lib/encryption/encryption.dart +++ b/lib/encryption/encryption.dart @@ -392,7 +392,8 @@ class DecryptException implements Exception { DecryptException(this.cause, [this.libolmMessage]); @override - String toString() => cause; + String toString() => + cause + (libolmMessage != null ? ': $libolmMessage' : ''); static const String notEnabled = 'Encryption is not enabled in your client.'; static const String unknownAlgorithm = 'Unknown encryption algorithm.'; diff --git a/lib/encryption/olm_manager.dart b/lib/encryption/olm_manager.dart index 592a6381..38db9325 100644 --- a/lib/encryption/olm_manager.dart +++ b/lib/encryption/olm_manager.dart @@ -305,6 +305,7 @@ class OlmManager { try { plaintext = session.session.decrypt(type, body); } catch (e) { + // The message was encrypted during this session, but is unable to decrypt throw DecryptException( DecryptException.decryptionFailed, e.toString()); }