import * as tsplus_module_1 from "@effect/core/stream/Channel/operations/failCause";
import * as tsplus_module_2 from "@effect/core/io/Cause/operations/failureOrCause";
import * as tsplus_module_3 from "@tsplus/stdlib/data/Either/fold";
import * as tsplus_module_4 from "@effect/core/stream/Channel/operations/catchAllCause";
/**
 * Returns a new channel that is the same as this one, except if this channel
 * errors for any typed error, then the returned channel will switch over to
 * using the fallback channel returned by the specified error handler.
 *
 * @tsplus fluent ets/Channel catchAll
 */

export function catchAll_(self, f) {
  return tsplus_module_4.catchAllCause_(self, cause => tsplus_module_3.fold_(tsplus_module_2.failureOrCause(cause), outErr => f(outErr), cause => tsplus_module_1.failCause(() => cause)));
}
/**
 * Returns a new channel that is the same as this one, except if this channel
 * errors for any typed error, then the returned channel will switch over to
 * using the fallback channel returned by the specified error handler.
 *
 * @tsplus static ets/Channel/Aspects catchAll
 */

export const catchAll = f => self => catchAll_(self, f);
//# sourceMappingURL=catchAll.mjs.map