Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Return valid type from Future.catchError. #151

Merged
merged 1 commit into from
Dec 22, 2020

Conversation

srawlins
Copy link
Contributor

An upcoming feature to the Dart analyzer 0 will report Future.catchError 1
onError handlers which return values of invalid type. Currently this is not
reported because the onError handler function type cannot be accurately
expressed. An onError handler for Future<T>.catchError must be either
FutureOr<T> Function(dynamic) or FutureOr<T> Function(dynamic, StackTrace).
In either case, the return type of the function is FutureOr<T>.

This CL corrects onError handler(s) to return a value of a valid type (typically null).

An upcoming feature to the Dart analyzer [0] will report Future.catchError [1]
`onError` handlers which return values of invalid type. Currently this is not
reported because the `onError` handler function type cannot be accurately
expressed. An `onError` handler for `Future<T>.catchError` must be either
`FutureOr<T> Function(dynamic)` or `FutureOr<T> Function(dynamic, StackTrace)`.
In either case, the return type of the function is `FutureOr<T>`.

This CL corrects `onError` handler(s) to return a value of a valid type (typically `null`).

[0]: dart-lang/sdk#35825
[1]: https://api.dart.dev/dev/2.12.0-149.0.dev/dart-async/Future/catchError.html
@google-cla google-cla bot added the cla: yes Google CLA signed label Dec 22, 2020
@srawlins srawlins merged commit 6c64d9e into dart-archive:master Dec 22, 2020
@srawlins srawlins deleted the catcherror branch December 22, 2020 21:41
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla: yes Google CLA signed
Development

Successfully merging this pull request may close these issues.

2 participants