import * as tsplus_module_1 from "@effect/core/io/Effect/operations/failCauseNow";
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/io/Effect/operations/onError";
import * as tsplus_module_5 from "@effect/core/io/Effect/operations/fork";
export const forkWithErrorHandler_ = forkWithErrorHandler_1;
/**
 * Like fork but handles an error with the provided handler.
 *
 * @tsplus fluent ets/Effect forkWithErrorHandler
 */

function forkWithErrorHandler_1(self, handler, __tsplusTrace) {
  return tsplus_module_5.fork(tsplus_module_4.onError_(self, cause => tsplus_module_3.fold_(tsplus_module_2.failureOrCause(cause), handler, tsplus_module_1.failCauseNow), __tsplusTrace), __tsplusTrace);
}
/**
 * Like fork but handles an error with the provided handler.
 *
 * @tsplus static ets/Effect/Aspects forkWithErrorHandler
 */


export function forkWithErrorHandler(handler, __tsplusTrace) {
  return self => forkWithErrorHandler_1(self, handler, __tsplusTrace);
}
//# sourceMappingURL=forkWithErrorHandler.mjs.map