// ets_tracing: off import type * as CS from "../../../../Cause/index.js" import * as T from "../../../../Effect/index.js" import type * as C from "../core.js" import * as CatchAllCause from "./catchAllCause.js" import * as FromEffect from "./fromEffect.js" /** * Runs the specified effect if this stream fails, providing the error to the effect if it exists. * * Note: Unlike `Effect.onError`, there is no guarantee that the provided effect will not be interrupted. */ export function onError_( self: C.Stream, cleanup: (c: CS.Cause) => T.Effect ): C.Stream { return CatchAllCause.catchAllCause_(self, (cause) => FromEffect.fromEffect(T.zipRight_(cleanup(cause), T.halt(cause))) ) } /** * Runs the specified effect if this stream fails, providing the error to the effect if it exists. * * Note: Unlike `Effect.onError`, there is no guarantee that the provided effect will not be interrupted. * * @ets_data_first onError_ */ export function onError(cleanup: (c: CS.Cause) => T.Effect) { return (self: C.Stream) => onError_(self, cleanup) }