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

Function liftThrowable

packages/effect/src/Option.ts:1003–1012  ·  view source on GitHub ↗
(
  f: (...a: A) => B
)

Source from the content-addressed store, hash-verified

1001 * @since 2.0.0
1002 */
1003export const liftThrowable = <A extends ReadonlyArray<unknown>, B>(
1004 f: (...a: A) => B
1005): (...a: A) => Option<B> =>
1006(...a) => {
1007 try {
1008 return some(f(...a))
1009 } catch {
1010 return none()
1011 }
1012}
1013
1014/**
1015 * Extracts the value from a `Some`, or throws a custom error for `None`.

Callers

nothing calls this directly

Calls 3

someFunction · 0.70
noneFunction · 0.70
fFunction · 0.50

Tested by

no test coverage detected