Skip to content
Permalink
Browse files
crypto: add causes to applicable webcrypto's OperationError
PR-URL: #44890
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
  • Loading branch information
panva authored and danielleadams committed Oct 11, 2022
1 parent 803fbfb commit 99a2c160401bfdafa3030f80ec2d11ed90dd4c14
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 12 deletions.
@@ -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(
@@ -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;
@@ -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;
@@ -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(
@@ -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 = {
@@ -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);
}

0 comments on commit 99a2c16

Please sign in to comment.