solid-file-client icon indicating copy to clipboard operation
solid-file-client copied to clipboard

Errors should use AggregateError for managing multiple errors.

Open CxRes opened this issue 5 years ago • 2 comments

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.

CxRes avatar Mar 13 '20 03:03 CxRes

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.

Otto-AA avatar Apr 24 '20 08:04 Otto-AA

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

CxRes avatar Apr 24 '20 09:04 CxRes