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

Function liftThrowable

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

Source from the content-addressed store, hash-verified

970 * @since 2.0.0
971 */
972export const liftThrowable = <A extends ReadonlyArray<unknown>, B>(
973 f: (...a: A) => B
974): (...a: A) => Option<B> =>
975(...a) => {
976 try {
977 return some(f(...a))
978 } catch {
979 return none()
980 }
981}
982
983/**
984 * 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