Skip to content

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

@ditman

Description

@ditman

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.

Metadata

Metadata

Assignees

Labels

area-web-jsIssues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop.type-enhancementA request for a change that isn't a bugweb-js-interopIssues that impact all js interop

Type

No type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions