flatMap<R extends Object> method
Returns noFutures(value), absorbing any throw from the callback into an
Err. The return type is widened from Ok<R> to Result<R> so the
absorbed error has a place to live.
Implementation
@override
@pragma('vm:prefer-inline')
Result<R> flatMap<R extends Object>(
@noFutures Result<R> Function(T value) noFutures,
) {
try {
return noFutures(unwrap());
} on Err catch (err) {
// Preserve a user-thrown Err's statusCode/breadcrumbs verbatim — the
// package contract is that thrown Err values propagate without being
// re-wrapped.
return err.transfErr<R>();
} catch (error, stackTrace) {
return Err<R>(error, stackTrace: stackTrace);
}
}