MCPcopy Create free account
hub / github.com/Effect-TS/effect / try_

Function try_

packages/effect/src/Result.ts:466–485  ·  view source on GitHub ↗
(
  evaluate: LazyArg<A> | {
    readonly try: LazyArg<A>
    readonly catch: (error: unknown) => E
  }
)

Source from the content-addressed store, hash-verified

464 ): Result<A, E>
465 <A>(evaluate: LazyArg<A>): Result<A, unknown>
466} = <A, E>(
467 evaluate: LazyArg<A> | {
468 readonly try: LazyArg<A>
469 readonly catch: (error: unknown) => E
470 }
471) => {
472 if (isFunction(evaluate)) {
473 try {
474 return succeed(evaluate())
475 } catch (e) {
476 return fail(e)
477 }
478 } else {
479 try {
480 return succeed(evaluate.try())
481 } catch (e) {
482 return fail(evaluate.catch(e))
483 }
484 }
485}
486
487export {
488 /**

Callers

nothing calls this directly

Calls 4

isFunctionFunction · 0.90
succeedFunction · 0.70
evaluateFunction · 0.70
failFunction · 0.70

Tested by

no test coverage detected