"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.catchAll = exports.catchAll_ = void 0;
const tracing_1 = __importStar(require("../../../../Tracing"));
const fileName_1 = "(@effect-ts/system): _src/Experimental/Stream/Channel/api/catchAll.ts";
const CS = __importStar(require("../../../../Cause"));
const E = __importStar(require("../../../../Either"));
const C = __importStar(require("../core"));
/**
 * 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.
 */
function catchAll_(self, f) {
    return C.catchAllCause_(self, (cause) => E.fold_(CS.failureOrCause(cause), (l) => f(l), (r) => C.failCause(r)));
}
exports.catchAll_ = catchAll_;
/**
 * 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.
 *
 * @ets_data_first catchAll_
 */
function catchAll(f) {
    return (self) => catchAll_(self, f);
}
exports.catchAll = catchAll;
//# sourceMappingURL=catchAll.js.map