Skip to content
This repository has been archived by the owner on Jan 26, 2022. It is now read-only.

Aggregate exception type vs. array of exceptions #11

Closed
domenic opened this issue Jan 30, 2019 · 6 comments
Closed

Aggregate exception type vs. array of exceptions #11

domenic opened this issue Jan 30, 2019 · 6 comments

Comments

@domenic
Copy link
Member

domenic commented Jan 30, 2019

The readme currently indicates that the rejection value would be an array of exceptions. Although this is not the worst thing, it definitely goes against prevailing practice to only throw exception types, and seems like it would play badly with lots of ecosystem code that assumes Error subclasses. For example, test frameworks or debugging tooling.

I have always hoped that the proposal for Promise.any would also introduce a new AggregateError type that contains a pointer to an array of exceptions.

@bakkot
Copy link
Collaborator

bakkot commented Jan 30, 2019

What would the message be?

@domenic
Copy link
Member Author

domenic commented Jan 30, 2019

Good question. Probably something generic, and unspecified, like all other message values?

@bakkot
Copy link
Collaborator

bakkot commented Jan 30, 2019

I guess what I mean is, what does new AggregateError(foo) do?

@ljharb
Copy link
Member

ljharb commented Jan 30, 2019

i'd assume the constructor would take two arguments - message and an array of errors

@sindresorhus
Copy link

For reference, my p-any package throws an AggregateError (using aggregate-error).

@MattiasBuelens
Copy link

Another reason why I would prefer AggregateError: you get a separate stack trace for where the aggregate error was thrown (i.e. where you called Promise.any). 🙂

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants