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

API description for catchError missing what the callback can take #16004

Open
sethladd opened this issue Jan 9, 2014 · 4 comments
Open

API description for catchError missing what the callback can take #16004

sethladd opened this issue Jan 9, 2014 · 4 comments
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. docs-api library-async type-documentation A request to add or improve documentation

Comments

@sethladd
Copy link
Contributor

sethladd commented Jan 9, 2014

Reported from developer:

According to https://api.dartlang.org/docs/channels/stable/latest/dart_async/Future.html#catchError

catchError(Function onError...

What is the typdef or signature for onError?

If I read the docs, I see: If the invocation returns true, onError is called with the error.

However, as of Dart 1.0, the callback can take one or two parameters:

(error)
(error, stackTrace)

Can we update the API docs for at least catchError to indicate what the callback can take?

@lrhn
Copy link
Member

lrhn commented May 5, 2014

Removed Type-Defect label.
Added Type-Documentation, Library-Async, Docs-API labels.

@sigmundch
Copy link
Member

We should also fix the documentation in runZoned.

https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/dart-async#id_runZoned

Currently the examples only show (error) => ..., but we should include one with a stack trace too.

@sethladd sethladd added type-documentation A request to add or improve documentation Priority-Unassigned area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-async docs-api labels May 20, 2014
@lrhn lrhn removed the core-a label Aug 11, 2017
@eernstg
Copy link
Member

eernstg commented Jan 18, 2018

Note that a similar issue arises for then, onError: #31928.

@eernstg
Copy link
Member

eernstg commented Jan 18, 2018

We might consider the following change (might be to much of a migration cost right now, though):

Future<T> catchError(
    FutureOr<T> Function(Object) onError, {bool test(Object error)});
Future<T> catchErrorAndStackTrace(
    FutureOr<T> Function(Object, StackTrace) onErrorWithStackTrace,
    {bool test(Object error)});

Developers would then need to use catchErrorAndStackTrace when they want the stack trace, and in return everybody would get better inferred types.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. docs-api library-async type-documentation A request to add or improve documentation
Projects
None yet
Development

No branches or pull requests

5 participants