import { pipe } from "../../Function";
import * as T from "../_internal/effect";
import { catchAllCause_ } from "./catchAllCause";
import { fromEffect } from "./fromEffect";
/**
 * 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, cleanup) {
  return catchAllCause_(self, cause => 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.
 */

export function onError(cleanup) {
  return self => onError_(self, cleanup);
}
//# sourceMappingURL=onError.js.map