-
Notifications
You must be signed in to change notification settings - Fork 9
spec: update second parameter of error constructor with options bag #26
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The "if options is an object and it has cause make a data property on O" pattern is repeated thrice here.
Perhaps an abstract operation that takes _O_
and _options_
that does the right thing would be appropriate? (perhaps "AddErrorCause" or something)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thanks
spec.emu
Outdated
1. <ins>If Type(_options_) is Object and ? HasProperty(_options_, `"cause"`) is *true*, then</ins> | ||
1. <ins>Let _cause_ be ? Get(_options_, `"cause"`)</ins> | ||
1. <ins>Perform ! CreateErrorObjectProperty(_O_, `"cause"`, _cause_).</ins> | ||
1. <ins>Return *undefined*.</ins> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this needed at all?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not required. I was assuming all abstract operations returning with values. If there are no such assumptions in ecma262, I'll remove this line.
Update the second parameter of the error constructor with an options bag. This helps to keep consistency between the DOMException signature and the Error constructor signature, i.e. DOMException may accept an options bag too as the second parameter and populate the cause property.