MCPcopy
hub / github.com/Effect-TS/effect / tryPromise

Function tryPromise

packages/effect/src/Micro.ts:1089–1102  ·  view source on GitHub ↗
(options: {
  readonly try: (signal: AbortSignal) => PromiseLike<A>
  readonly catch: (error: unknown) => E
})

Source from the content-addressed store, hash-verified

1087 * @category constructors
1088 */
1089export const tryPromise = <A, E>(options: {
1090 readonly try: (signal: AbortSignal) => PromiseLike<A>
1091 readonly catch: (error: unknown) => E
1092}): Micro<A, E> =>
1093 asyncOptions<A, E>(function(resume, signal) {
1094 try {
1095 options.try(signal!).then(
1096 (a) => resume(succeed(a)),
1097 (e) => resume(fail(options.catch(e)))
1098 )
1099 } catch (err) {
1100 resume(fail(options.catch(err)))
1101 }
1102 }, options.try.length !== 0)
1103
1104/**
1105 * Create a `Micro` effect using the current `MicroFiber`.

Callers 1

core-effect.tsFile · 0.85

Calls 3

resumeFunction · 0.70
failFunction · 0.70
succeedFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…