change: Olm exception handling

This commit is contained in:
Christian Pauly 2021-02-03 11:01:01 +01:00
parent 64a4c0f565
commit 9fac03639e
2 changed files with 3 additions and 1 deletions

View File

@ -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.';

View File

@ -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());
}