/** * Takes some fiber failures and converts them into errors, using the * specified function to convert the `E` into an `E1 | E2`. * * @tsplus static effect/core/io/Effect.Aspects unrefineWith * @tsplus pipeable effect/core/io/Effect unrefineWith */ export function unrefineWith( pf: (u: unknown) => Maybe, f: (e: E) => E2 ) { return (self: Effect): Effect => self.catchAllCause( (cause): Effect => cause .find((c) => (c.isDieType() ? pf(c.value) : Maybe.none)) .fold(Effect.failCause(cause.map(f)), Effect.fail) ) }