import * as tsplus_module_1 from "@effect/core/io/Effect/definition";
import * as tsplus_module_2 from "@effect/core/io/Exit/operations/fail";
import * as tsplus_module_3 from "@effect/core/io/Effect/operations/succeedWith";
/**
 * Imports a synchronous side-effect into a pure `Effect` value, translating any
 * thrown exceptions into typed failed effects creating with `Effect.fail`.
 *
 * @tsplus static ets/Effect/Ops attempt
 */

export function attempt(f, __tsplusTrace) {
  return tsplus_module_3.succeedWith(runtimeConfig => {
    try {
      return f();
    } catch (error) {
      if (!runtimeConfig.value.fatal(error)) {
        throw new tsplus_module_1.Effect.Error(tsplus_module_2.fail(error), __tsplusTrace);
      }

      throw error;
    }
  }, __tsplusTrace);
}
//# sourceMappingURL=attempt.mjs.map