// ets_tracing: off import { failureOrCause } from "../Cause/index.js" import * as E from "../Either/index.js" import { chain_, foldCauseM_, halt, succeed } from "./core.js" import type { Effect } from "./effect.js" /** * Returns an effect that effectfully "peeks" at the failure of this effect. */ export function tapError_( self: Effect, f: (e: E) => Effect, __trace?: string ) { return foldCauseM_( self, (c) => E.fold_( failureOrCause(c), (e) => chain_(f(e), () => halt(c)), (_) => halt(c) ), succeed, __trace ) } /** * Returns an effect that effectfully "peeks" at the failure of this effect. * * @ets_data_first tapError_ */ export function tapError( f: (e: E) => Effect, __trace?: string ) { return (self: Effect) => tapError_(self, f, __trace) }