import * as tsplus_module_1 from "@effect/core/io/Effect/operations/failCause";
import * as tsplus_module_2 from "@effect/core/io/Effect/operations/zipRight";
import * as tsplus_module_3 from "@effect/core/stream/Stream/operations/fromEffect";
import * as tsplus_module_4 from "@effect/core/stream/Stream/operations/catchAllCause";
/**
 * 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.
 *
 * @tsplus fluent ets/Stream onError
 */

export function onError_(self, cleanup, __tsplusTrace) {
  return tsplus_module_4.catchAllCause_(self, cause => tsplus_module_3.fromEffect(() => tsplus_module_2.zipRight_(cleanup(cause), () => tsplus_module_1.failCause(() => cause, __tsplusTrace), __tsplusTrace), __tsplusTrace), __tsplusTrace);
}
/**
 * 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.
 *
 * @tsplus static ets/Stream/Aspects onError
 */

export const onError = (cleanup, __tsplusTrace) => self => onError_(self, cleanup, __tsplusTrace);
//# sourceMappingURL=onError.mjs.map