flatMapOptionOrFail<B> method

ZIO<R, E, B> flatMapOptionOrFail<B>(
  1. Option<B> f(
    1. A _
    ),
  2. E onNone(
    1. A _
    )
)

A variant of flatMap that uses the resulting Option to determine the result.

Some values are mapped to the success channel, and if the value is None, the resulting ZIO will fail with onNone.

Implementation

ZIO<R, E, B> flatMapOptionOrFail<B>(
  Option<B> Function(A _) f,
  E Function(A _) onNone,
) =>
    flatMapEither((a) => Either.fromOption(f(a), () => onNone(a)));