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

Errors should use AggregateError for managing multiple errors. #131

Open
CxRes opened this issue Mar 13, 2020 · 2 comments
Open

Errors should use AggregateError for managing multiple errors. #131

CxRes opened this issue Mar 13, 2020 · 2 comments
Labels
enhancement New feature or request

Comments

@CxRes
Copy link
Contributor

CxRes commented Mar 13, 2020

TC39 has proposed a new type of Error object AggregateError for handling multiple errors (Stage 3). They use it capture error from Promise.any(). But similar ideas have been used by userland libraries in the past. And now it is official and polyfills are also available.

Please consider the use of AggregateError to consolidate error messages.

@jeff-zucker jeff-zucker added the enhancement New feature or request label Apr 20, 2020
@Otto-AA
Copy link
Contributor

Otto-AA commented Apr 24, 2020

I've looked at it again, and realized that AggregateError is conceptually different than our implementation. When we throw in copy, we provide information on what requests failed and what requests succeeded. Using AggregateError we would only provide on information on the failures.

So if we'd want to use it, we would need to extend it and add support for successful responses. We use a Promise.allSettled method¹, which has success and failure outcomes. The error thrown would need to reflect this.

¹ and we probably shouldn't write the polyfill for allSettled ourselves here but just let babel do it.

@CxRes
Copy link
Contributor Author

CxRes commented Apr 24, 2020

In my code, what I do is add a success property to AggregateError. Its not ideal but is standards compliant!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants