diff --git a/lib/internal/crypto/aes.js b/lib/internal/crypto/aes.js index 79ca61c5ff2097..862d5127448ec4 100644 --- a/lib/internal/crypto/aes.js +++ b/lib/internal/crypto/aes.js @@ -241,11 +241,10 @@ async function aesGenerateKey(algorithm, extractable, keyUsages) { } const key = await generateKey('aes', { length }).catch((err) => { - // TODO(@panva): add err as cause to DOMException throw lazyDOMException( 'The operation failed for an operation-specific reason' + `[${err.message}]`, - 'OperationError'); + { name: 'OperationError', cause: err }); }); return new InternalCryptoKey( diff --git a/lib/internal/crypto/cfrg.js b/lib/internal/crypto/cfrg.js index 17358c7ccca23d..2b40f152b1e433 100644 --- a/lib/internal/crypto/cfrg.js +++ b/lib/internal/crypto/cfrg.js @@ -150,10 +150,9 @@ async function cfrgGenerateKey(algorithm, extractable, keyUsages) { } const keyPair = await generateKeyPair(genKeyType).catch((err) => { - // TODO(@panva): add err as cause to DOMException throw lazyDOMException( 'The operation failed for an operation-specific reason', - 'OperationError'); + { name: 'OperationError', cause: err }); }); let publicUsages; diff --git a/lib/internal/crypto/ec.js b/lib/internal/crypto/ec.js index ed7484dbbb596e..c235de5202957e 100644 --- a/lib/internal/crypto/ec.js +++ b/lib/internal/crypto/ec.js @@ -112,10 +112,9 @@ async function ecGenerateKey(algorithm, extractable, keyUsages) { } const keypair = await generateKeyPair('ec', { namedCurve }).catch((err) => { - // TODO(@panva): add err as cause to DOMException throw lazyDOMException( 'The operation failed for an operation-specific reason', - 'OperationError'); + { name: 'OperationError', cause: err }); }); let publicUsages; diff --git a/lib/internal/crypto/mac.js b/lib/internal/crypto/mac.js index 15b3378e2eda64..81bdd5f770c5c5 100644 --- a/lib/internal/crypto/mac.js +++ b/lib/internal/crypto/mac.js @@ -66,10 +66,9 @@ async function hmacGenerateKey(algorithm, extractable, keyUsages) { } const key = await generateKey('hmac', { length }).catch((err) => { - // TODO(@panva): add err as cause to DOMException throw lazyDOMException( 'The operation failed for an operation-specific reason', - 'OperationError'); + { name: 'OperationError', cause: err }); }); return new InternalCryptoKey( diff --git a/lib/internal/crypto/rsa.js b/lib/internal/crypto/rsa.js index fa6928e4d78f06..eb407c7b4dcf52 100644 --- a/lib/internal/crypto/rsa.js +++ b/lib/internal/crypto/rsa.js @@ -178,10 +178,9 @@ async function rsaKeyGenerate( modulusLength, publicExponent: publicExponentConverted, }).catch((err) => { - // TODO(@panva): add err as cause to DOMException throw lazyDOMException( 'The operation failed for an operation-specific reason', - 'OperationError'); + { name: 'OperationError', cause: err }); }); const keyAlgorithm = { diff --git a/lib/internal/crypto/util.js b/lib/internal/crypto/util.js index dbd816cff99e9f..f4e2b1ad6fc123 100644 --- a/lib/internal/crypto/util.js +++ b/lib/internal/crypto/util.js @@ -279,10 +279,9 @@ const validateByteSource = hideStackFrames((val, name) => { function onDone(resolve, reject, err, result) { if (err) { - // TODO(@panva): add err as cause to DOMException return reject(lazyDOMException( 'The operation failed for an operation-specific reason', - 'OperationError')); + { name: 'OperationError', cause: err })); } resolve(result); }