Error raised by crypto-kms providers, carrying a stable KmsErrorCode.
Branch on code rather than on the message text, which may change.
code
try { await kms.decrypt(keyId, ciphertext, context);} catch (err) { if (err instanceof KmsError && err.code === "DECRYPTION_FAILED") { // wrong context or tampered ciphertext } throw err;} Copy
try { await kms.decrypt(keyId, ciphertext, context);} catch (err) { if (err instanceof KmsError && err.code === "DECRYPTION_FAILED") { // wrong context or tampered ciphertext } throw err;}
Create a KMS error with a code, a message and the key it concerns.
Optional
Readonly
Always "KmsError".
"KmsError"
Machine-readable reason.
The key the failing operation addressed, when there was one.
Error raised by crypto-kms providers, carrying a stable KmsErrorCode.
Branch on
coderather than on the message text, which may change.Example