forked from mystiq/hydrogen-web
give better error when olm plaintext is not json
This commit is contained in:
parent
1f8005cdfd
commit
b2fffee037
1 changed files with 6 additions and 1 deletions
|
@ -111,7 +111,12 @@ export class Decryption {
|
|||
plaintext = createResult.plaintext;
|
||||
}
|
||||
if (typeof plaintext === "string") {
|
||||
const payload = JSON.parse(plaintext);
|
||||
let payload;
|
||||
try {
|
||||
payload = JSON.parse(plaintext);
|
||||
} catch (err) {
|
||||
throw new DecryptionError("Could not JSON decode plaintext", event, {plaintext, err});
|
||||
}
|
||||
this._validatePayload(payload, event);
|
||||
return {event: payload, senderKey};
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue