diff --git a/dom/media/eme/DetailedPromise.cpp b/dom/media/eme/DetailedPromise.cpp index dc682ba9e971..de11d9841d7d 100644 --- a/dom/media/eme/DetailedPromise.cpp +++ b/dom/media/eme/DetailedPromise.cpp @@ -35,23 +35,29 @@ DetailedPromise::~DetailedPromise() { MaybeReportTelemetry(kFailed); } -void DetailedPromise::MaybeReject(nsresult aArg, const nsACString& aReason) { +void DetailedPromise::LogRejectionReason(uint32_t aErrorCode, + const nsACString& aReason) { nsPrintfCString msg("%s promise rejected 0x%" PRIx32 " '%s'", mName.get(), - static_cast(aArg), - PromiseFlatCString(aReason).get()); + aErrorCode, PromiseFlatCString(aReason).get()); EME_LOG("%s", msg.get()); MaybeReportTelemetry(kFailed); LogToBrowserConsole(NS_ConvertUTF8toUTF16(msg)); +} + +void DetailedPromise::MaybeReject(nsresult aArg, const nsACString& aReason) { + LogRejectionReason(static_cast(aArg), aReason); ErrorResult rv; rv.ThrowDOMException(aArg, aReason); Promise::MaybeReject(rv); } -void DetailedPromise::MaybeReject(ErrorResult&, const nsACString& aReason) { - MOZ_ASSERT_UNREACHABLE("nsresult expected in MaybeReject()"); +void DetailedPromise::MaybeReject(ErrorResult& aArg, + const nsACString& aReason) { + LogRejectionReason(aArg.ErrorCodeAsInt(), aReason); + Promise::MaybeReject(aArg); } /* static */ diff --git a/dom/media/eme/DetailedPromise.h b/dom/media/eme/DetailedPromise.h index ac0fc40a61b1..75697c827da3 100644 --- a/dom/media/eme/DetailedPromise.h +++ b/dom/media/eme/DetailedPromise.h @@ -41,7 +41,7 @@ class DetailedPromise : public Promise { void MaybeReject(nsresult aArg, const nsACString& aReason); void MaybeReject(ErrorResult& aArg) = delete; - void MaybeReject(ErrorResult&, const nsACString& aReason); + void MaybeReject(ErrorResult& aArg, const nsACString& aReason); private: explicit DetailedPromise(nsIGlobalObject* aGlobal, const nsACString& aName); @@ -53,6 +53,7 @@ class DetailedPromise : public Promise { enum eStatus { kSucceeded, kFailed }; void MaybeReportTelemetry(eStatus aStatus); + void LogRejectionReason(uint32_t aErrorCode, const nsACString& aReason); nsCString mName; bool mResponded;