Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document AggregateError: errors #7116

Merged
merged 1 commit into from
Jul 21, 2021

Conversation

sideshowbarker
Copy link
Collaborator

@sideshowbarker sideshowbarker commented Jul 21, 2021

Fixes #7106


This one is exceptional in that the errors property is not a property of the prototype but is instead dynamically created on instantiation of the AggregateError object. See step 5 of the algorithm in the spec at https://tc39.es/ecma262/multipage/fundamental-objects.html#sec-aggregate-error

A precedent here is RegExp: lastIndex https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/lastIndex, which we discussed in #2725.

Note also: this PR doesn’t add a separate new article for AggregateError: errors but intentionally just documents it in the AggregateError article itself. There’s really not a whole lot more which needs to be said that would justify a separate article.

(And the AggregateError.prototype.message and AggregateError.prototype.name links aren’t actually to separate articles specific to AggregateError, but instead just redirect to the Error.prototype.message and Error.prototype.name articles.)

@github-actions
Copy link
Contributor

Copy link
Member

@Elchi3 Elchi3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just reviewed this using the markdown rich diff in the GitHub UI and it is sooo nice! 😢😢😢
This is the future, great stuff! 👍

@Elchi3 Elchi3 merged commit 1cf1797 into main Jul 21, 2021
@Elchi3 Elchi3 deleted the sideshowbarker/aggregateerror-errors-property branch July 21, 2021 10:08
@InExtremaRes
Copy link

@sideshowbarker Thank you.

I'm somewhat late but, do you think that could be important to specify that the property is writable, non-enumerable and the array is also mutable for a given instance (i.e. not frozen or similar)? I remember seeing a very long discussion in the proposal regarding this property and if the array should be frozen, if a brand new array should be returned every time, if a new internal slot should be accessed, etc. So I guess those aren't obvious and someone could expect some behaviour it doesn't have.

And BTW, doesn't message work more or less that way as well? For what I understand from https://tc39.es/ecma262/multipage/fundamental-objects.html#sec-error-message (and other Error's constructors, as AggregateError) the constructor defines the property in the instance, but only if a message is passed to the constructor, in which case there is also an own, non-enumerable, mutable property in the instance.

@sideshowbarker
Copy link
Collaborator Author

do you think that could be important to specify that the property is writable, non-enumerable and the array is also mutable for a given instance (i.e. not frozen or similar)?

Yeah, that seems like useful information to add. Would you be interested in writing up a PR for it?

doesn't message work more or less that way as well? For what I understand from tc39.es/ecma262/multipage/fundamental-objects.html#sec-error-message (and other Error's constructors, as AggregateError) the constructor defines the property in the instance, but only if a message is passed to the constructor, in which case there is also an own, non-enumerable, mutable property in the instance

Yeah, that all sounds right (though without testing it or going back and reading the spec, I’m not certain)

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Issue with "AggregateError": (there is no section/link/reference to property "errors")
3 participants