From 3d7a95ab4426eab9071613f31a254f3f027d399f Mon Sep 17 00:00:00 2001 From: Moonchild Date: Wed, 5 Feb 2025 22:51:26 +0100 Subject: [PATCH] Issue #2690 - Convert error from non-existing convenience function. Didn't check that the convenience function existed for this. Throw the error manually, instead. TO-DO: Add these convenience functions for one-shot errors. --- dom/bindings/Errors.msg | 1 + dom/crypto/WebCryptoTask.cpp | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/dom/bindings/Errors.msg b/dom/bindings/Errors.msg index d22ef2c27f..db689e5bc0 100644 --- a/dom/bindings/Errors.msg +++ b/dom/bindings/Errors.msg @@ -43,6 +43,7 @@ MSG_DEF(MSG_GLOBAL_NOT_NATIVE, 0, JSEXN_TYPEERR, "Global is not a native object. MSG_DEF(MSG_ENCODING_NOT_SUPPORTED, 1, JSEXN_RANGEERR, "The given encoding '{0}' is not supported.") MSG_DEF(MSG_DOM_ENCODING_NOT_UTF, 0, JSEXN_RANGEERR, "The encoding must be utf-8, utf-16, or utf-16be.") MSG_DEF(MSG_DOM_DECODING_FAILED, 0, JSEXN_TYPEERR, "Decoding failed.") +MSG_DEF(MSG_DOM_OPERATION_FAILED, 0, JSEXN_TYPEERR, "The operation could not be performed.") MSG_DEF(MSG_NOT_FINITE, 1, JSEXN_TYPEERR, "{0} is not a finite floating-point value.") MSG_DEF(MSG_INVALID_VERSION, 0, JSEXN_TYPEERR, "0 (Zero) is not a valid database version.") MSG_DEF(MSG_INVALID_BYTESTRING, 2, JSEXN_TYPEERR, "Cannot convert string to ByteString because the character" diff --git a/dom/crypto/WebCryptoTask.cpp b/dom/crypto/WebCryptoTask.cpp index b8239b9046..644afaf6f3 100644 --- a/dom/crypto/WebCryptoTask.cpp +++ b/dom/crypto/WebCryptoTask.cpp @@ -402,8 +402,9 @@ WebCryptoTask::FailWithError(nsresult aRv) MOZ_ASSERT(IsOnOriginalThread()); if (aRv == NS_ERROR_DOM_TYPE_MISMATCH_ERR) { - mResultPromise->MaybeRejectWithTypeError( - "The operation could not be performed."); + ErrorResult rv; + rv.ThrowTypeError(); + mResultPromise->MaybeReject(rv); } else { // Blindly convert nsresult to DOMException // Individual tasks must ensure they pass the right values