Error handling when encrypting the verification email fails

This commit is contained in:
Thomas Oberndörfer 2019-03-12 10:45:06 +01:00
parent 9159bd5a47
commit b83f13cde2

View File

@ -89,12 +89,17 @@ class Email {
const now = new Date(); const now = new Date();
// set message creation date if key has been created with future creation date // set message creation date if key has been created with future creation date
const msgCreationDate = key.primaryKey.created > now ? key.primaryKey.created : now; const msgCreationDate = key.primaryKey.created > now ? key.primaryKey.created : now;
try {
const ciphertext = await openpgp.encrypt({ const ciphertext = await openpgp.encrypt({
message: openpgp.message.fromText(plaintext), message: openpgp.message.fromText(plaintext),
publicKeys: key, publicKeys: key,
date: msgCreationDate date: msgCreationDate
}); });
return ciphertext.data; return ciphertext.data;
} catch (error) {
log.error('email', 'Encrypting message failed.', error, publicKeyArmored);
util.throw(400, 'Encrypting message for verification email failed.', error);
}
} }
/** /**