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

[web] Improve error messages in Future.toJS #56898

Open
ditman opened this issue Oct 14, 2024 · 1 comment
Open

[web] Improve error messages in Future.toJS #56898

ditman opened this issue Oct 14, 2024 · 1 comment
Assignees
Labels
area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. type-enhancement A request for a change that isn't a bug web-js-interop Issues that impact all js interop

Comments

@ditman
Copy link
Member

ditman commented Oct 14, 2024

The current implementation of Future.toJS (here, here) handles errors coming from the Dart future by rejecting a JS Promise.

This is great so JS code knows that something failed within Dart, but the debugging experience of what happened is not great, because the error text is hardcoded to:

Dart exception thrown from converted Future. Use the properties 'error' to fetch the boxed error and 'stack' to recover the stack trace.

As a JS programmer, I find it odd that I need to unbox objects contained in the emitted error, instead of having a textual description of what's wrong.

In the Flutter engine we're trying something like this, but it'd be nice to have a Future.toJS that exposes the "text" of the underlying error directly in the JS console, so we can stop using a bespoke solution.

@dart-github-bot
Copy link
Collaborator

Summary: The Future.toJS method currently provides a generic error message when a Dart future fails, making it difficult for JavaScript developers to understand the root cause of the error. The user proposes improving the error message by directly exposing the error text in the JS console, enhancing debugging experience.

@dart-github-bot dart-github-bot added area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. triage-automation See https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot. type-enhancement A request for a change that isn't a bug labels Oct 14, 2024
@lrhn lrhn added web-js-interop Issues that impact all js interop and removed triage-automation See https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot. labels Oct 15, 2024
@srujzs srujzs self-assigned this Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. type-enhancement A request for a change that isn't a bug web-js-interop Issues that impact all js interop
Projects
Status: No status
Development

No branches or pull requests

4 participants