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

Function try_

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

Source from the content-addressed store, hash-verified

449 ): Result<A, E>
450 <A>(evaluate: LazyArg<A>): Result<A, unknown>
451} = <A, E>(
452 evaluate: LazyArg<A> | {
453 readonly try: LazyArg<A>
454 readonly catch: (error: unknown) => E
455 }
456) => {
457 if (isFunction(evaluate)) {
458 try {
459 return succeed(evaluate())
460 } catch (e) {
461 return fail(e)
462 }
463 } else {
464 try {
465 return succeed(evaluate.try())
466 } catch (e) {
467 return fail(evaluate.catch(e))
468 }
469 }
470}
471
472export {
473 /**

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