onFutureError<T> method
Race a Future, but only handle errors.
Successful completion is ignored. Use for error monitoring or when you want to react only to failure cases.
Example:
await XSelect.run<String>((s) => s
..onStream(dataStream, (data) => 'Processing: $data')
..onFutureError(backgroundTask(), (error) => 'Task failed: $error')
..onTimeout(Duration(seconds: 30), () => 'timeout')
);
See also:
- onFuture - Parent
- onFutureValue - Only handle value
Implementation
SelectBuilder<R> onFutureError<T>(
Future<T> fut, FutureOr<R> Function(Object error) body,
{Object? tag, bool Function()? if_}) {
return onFuture<T>(fut.catchError((Object e) => throw e),
(_) => throw StateError('onFutureError should not handle success'),
tag: tag, if_: if_);
}