Closed Bug 1971000 Opened 2 months ago Closed 2 months ago

`SuppressedError` constructor should not accept `cause` argument

Categories

(Core :: JavaScript: Standard Library, defect)

Firefox 141
defect

Tracking

()

RESOLVED FIXED
141 Branch
Tracking Status
firefox141 --- fixed

People

(Reporter: zloirock, Assigned: debadree333)

Details

Attachments

(1 file)

Steps to reproduce:

new SuppressedError(1, 2, 3, { cause: 4 }).cause

Actual results:

4

Expected results:

undefined

Component: Untriaged → JavaScript: Standard Library
Product: Firefox → Core

Thank you for reporting!

Indeed, the SuppressedError constructor doesn't receive the options parameter.

https://arai-a.github.io/ecma262-compare/?pr=3000&id=sec-suppressederror

SuppressedError ( error, suppressed, message )

According to the following issue, not having the cause support is intentional.

https://github.com/tc39/proposal-explicit-resource-management/issues/147

Thus, we should skip the options handling for SuppressedError below

https://searchfox.org/mozilla-central/rev/1c29c547ab9f7d29a02c2b6e7f4f4a9facfe94fd/js/src/vm/ErrorObject.cpp#268-286

bool hasOptions = args.get(messageArg + 1).isObject();

Rooted<mozilla::Maybe<Value>> cause(cx, mozilla::Nothing());
if (hasOptions) {
  RootedObject options(cx, &args[messageArg + 1].toObject());

  bool hasCause = false;
  if (!HasProperty(cx, options, cx->names().cause, &hasCause)) {
    return nullptr;
  }

  if (hasCause) {
    RootedValue causeValue(cx);
    if (!GetProperty(cx, options, options, cx->names().cause, &causeValue)) {
      return nullptr;
    }
    cause = mozilla::Some(causeValue.get());
  }
}
Status: UNCONFIRMED → NEW
Ever confirmed: true
Assignee: nobody → debadree333
Status: NEW → ASSIGNED
Status: ASSIGNED → RESOLVED
Closed: 2 months ago
Resolution: --- → FIXED
Target Milestone: --- → 141 Branch
QA Whiteboard: [qa-triage-done-c142/b141]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: