Skip to content

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

Merged
domenic merged 3 commits intowhatwg:mainfrom
jeremyroman:invoke-call-construct
Aug 2, 2024
Merged

Allow users of "invoke a callback function" to report the exception#1424
domenic merged 3 commits intowhatwg:mainfrom
jeremyroman:invoke-call-construct

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.

@domenic domenic merged commit 192be41 into whatwg:main Aug 2, 2024
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