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

Allow users of "invoke a callback function" to report the exception #1424

Merged
merged 3 commits into from
Aug 2, 2024

Conversation

jeremyroman
Copy link
Contributor

@jeremyroman jeremyroman commented Jul 31, 2024

This makes it more concise for users to, as is frequently desired for undefined-returning callbacks especially, immediately catch and report the exception rather than needing to handle it themselves.

This isn't appropriate for other types of callback functions, where a result may be expected or the exception needs to be rethrown. Callers need to explicitly decide which behavior they want, unless the callback returns a promise type, in which case exceptions are turned into rejected promises implicitly.

Fixes #1423.

  • At least two implementers are interested (and none opposed): n/a; no normative change
  • Tests are written and can be reviewed and commented upon at: n/a; no normative change
  • Implementation bugs are filed: n/a; no normative change
  • MDN issue is filed: n/a; no normative change
  • The top of this comment includes a clear commit message to use.

(See WHATWG Working Mode: Changes for more details.)


Preview | Diff

This makes it more concise for users to, as is frequently desired for
undefined-returning callbacks especially, immediately catch and report
the exception rather than needing to handle it themselves.

This isn't appropriate for other types of callback functions, where a
result may be expected or the exception needs to be rethrown. Callers
need to explicitly decide which behavior they want, unless the callback
returns a promise type, in which case exceptions are turned into
rejected promises implicitly.

Fixes whatwg#1423.
@jeremyroman
Copy link
Contributor Author

@domenic ptal?

Copy link
Member

@domenic domenic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with nit.

index.bs Outdated Show resolved Hide resolved
@domenic domenic merged commit 192be41 into whatwg:main Aug 2, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Handle exceptions when calling callbacks by default
2 participants