Closed Bug 1783664 Opened 2 years ago Closed 2 years ago

Add a helper method to construct a rejected Promise

Categories

(Core :: DOM: Core & HTML, enhancement)

enhancement

Tracking

()

RESOLVED FIXED
105 Branch
Tracking Status
firefox105 --- fixed

People

(Reporter: saschanaz, Assigned: saschanaz)

References

Details

Attachments

(1 file)

There are multiple lines in dom/streams that creates a rejected promise, e.g. https://searchfox.org/mozilla-central/rev/5644fae86d5122519a0e34ee03117c88c6ed9b47/dom/streams/ReadableStream.cpp#371-377.

RefPtr<Promise> promise = Promise::Create(aStream->GetParentObject(), aRv);
if (aRv.Failed()) {
  return nullptr;
}
JS::Rooted<JS::Value> storedError(aCx, aStream->StoredError());
promise->MaybeReject(storedError);
return promise.forget();

A helper function can reduce this to:

JS::Rooted<JS::Value> storedError(aCx, aStream->StoredError());
return Promise::CreateRejected(storedError, aRv);
See Also: → 1736461
Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 105 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: