mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 03:25:12 +01:00
give better error when olm plaintext is not json
This commit is contained in:
parent
1f8005cdfd
commit
b2fffee037
@ -111,7 +111,12 @@ export class Decryption {
|
|||||||
plaintext = createResult.plaintext;
|
plaintext = createResult.plaintext;
|
||||||
}
|
}
|
||||||
if (typeof plaintext === "string") {
|
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);
|
this._validatePayload(payload, event);
|
||||||
return {event: payload, senderKey};
|
return {event: payload, senderKey};
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user