-
Notifications
You must be signed in to change notification settings - Fork 32
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
Create a jagged AggregateError
during DisposeResources()
#104
Conversation
A preview of this PR can be found at https://tc39.es/proposal-explicit-resource-management/pr/104. |
With this change, I am wondering if we should always create an try {
using c = { [Symbol.dispose]() { throw new Error("c"); };
using b = { [Symbol.dispose]() { throw new Error("b"); };
} catch (e) {
e
} What should the shape of
Option (1) above will always wrap errors raised during I also wonder if /cc: @ljharb |
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.
A couple small bugs:
- The errors parameter to DisposeResources is never supplied and never used. Delete it?
- A couple references to a nonexistent variable error. Should those be disposeError?
I don't have any strong opinions on option (1) vs option (2). Both have their merits. |
@ljharb: Do you have any thoughts on #104 (comment)? You've expressed interest in how the |
Thanks, these should be addressed in db4a190. |
I also don't have strong opinions on option 1 vs 2. I can't really recall why we need a |
Ideally we want to be able to easily determine the original exception from the body. Putting both in try {
using c = { [Symbol.dispose]() { if(randomBool()) throw new Error("c"); };
{
using b = { [Symbol.dispose]() { if(randomBool()) throw new Error("b"); };
if(randomBool()) throw new Error("a");
}
} catch (e) {
e
} If we use
You can walk down the If we just used
Now, instead of traversing That begs the question posed in #74: Given that other operations can produce an
There's no actual aggregation since the errors are nested, not flat. The shape of the object graph doesn't change regardless
Its arguably not that important to know whether an exception was specifically raised from the body or from a dispose. If it is important to know whether the exception came from a dispose, then I'd suggest calling it a |
ahhh ok, so That makes sense to me, as named - |
Superseded by #117. |
This change creates a jagged
AggregateError
inDisposeResources()
such that the exceptions caught in the following two cases are identical:Per plenary, we will continue to use
AggregateError
rather than introducing a new error for this case.Fixes #74