MCPcopy
hub / github.com/monkeytypegame/monkeytype / tryCatch

Function tryCatch

packages/util/src/trycatch.ts:15–24  ·  view source on GitHub ↗
(
  promiseOrFunction: Promise<T>,
)

Source from the content-addressed store, hash-verified

13type Result<T, E = Error> = Success<T> | Failure<E>;
14
15export async function tryCatch<T, E = Error>(
16 promiseOrFunction: Promise<T>,
17): Promise<Result<T, E>> {
18 try {
19 let data = await promiseOrFunction;
20 return { data, error: null };
21 } catch (error) {
22 return { data: null, error: error as E };
23 }
24}
25
26export function tryCatchSync<T, E = Error>(fn: () => T): Result<T, E> {
27 try {

Callers 15

trycatch.spec.tsFile · 0.90
signInFunction · 0.90
signInWithProviderFunction · 0.90
signInWithPopupFunction · 0.90
setupFunction · 0.90
getQuotesMethod · 0.90
WordFilterModalFunction · 0.90
fetchLatestVersionFunction · 0.90
initFunction · 0.90
activateFunction · 0.90
getLatestFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected