import * as tsplus_module_1 from "@effect/core/io/Effect/operations/failNow";
import * as tsplus_module_2 from "@effect/core/io/Effect/operations/failCauseNow";
import * as tsplus_module_3 from "@effect/core/io/Cause/operations/failureOrCause";
import * as tsplus_module_4 from "@tsplus/stdlib/data/Either/fold";
import * as tsplus_module_5 from "@effect/core/io/Effect/operations/succeedNow";
import * as tsplus_module_6 from "@effect/core/io/Effect/operations/foldCauseEffect";
/**
 * Returns an effect with its error channel mapped using the specified
 * function. This can be used to lift a "smaller" error into a "larger" error.
 *
 * @tsplus fluent ets/Effect mapError
 */

export function mapError_(self, f, __tsplusTrace) {
  return tsplus_module_6.foldCauseEffect_(self, cause => tsplus_module_4.fold_(tsplus_module_3.failureOrCause(cause), e => tsplus_module_1.failNow(f(e), __tsplusTrace), tsplus_module_2.failCauseNow), tsplus_module_5.succeedNow, __tsplusTrace);
}
/**
 * Returns an effect with its error channel mapped using the specified
 * function. This can be used to lift a "smaller" error into a "larger" error.
 *
 * @tsplus static ets/Effect/Aspects mapError
 */

export const mapError = (f, __tsplusTrace) => self => mapError_(self, f, __tsplusTrace);
//# sourceMappingURL=mapError.mjs.map