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

Should 'using' suppress exceptions from @@dispose when already throwing an exception #19

Closed
rbuckton opened this issue Aug 3, 2018 · 3 comments

Comments

@rbuckton
Copy link
Collaborator

rbuckton commented Aug 3, 2018

This was brought up by @waldemarhorwat in the July TC39 meeting. Java's try-with-resources block will suppress exceptions raised when disposing resources if already propagating an exception from the body.

However, there are two points that cause me concern about adopting this behavior:

  • This behavior would differ significantly from a regular try..finally statement.
  • Java has a way to retrieve these suppressed exceptions by calling the Throwable.getSuppressed() method on the exception thrown. ECMAScript does not have a reliable way to provide this as it is possible to throw a non-Error value.

Should we consider following Java's lead here and perform the same suppression?

@littledan
Copy link
Member

My intuition here is to match try/finally and not suppress the error, but this is not a strongly held opinion.

@benjamingr
Copy link

benjamingr commented Aug 29, 2018

I think we should not suppress the exception. I can gather more feedback from Node if you'd like :)

@rbuckton
Copy link
Collaborator Author

Addressed by the addition of AggregateError in #26.

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

No branches or pull requests

3 participants