MCPcopy Create free account
hub / github.com/Openpanel-dev/openpanel / tryCatch

Function tryCatch

packages/common/src/try-catch.ts:5–15  ·  view source on GitHub ↗
(
  input: (() => Promise<T>) | Promise<T>,
)

Source from the content-addressed store, hash-verified

3 | { ok: false; data: null; error: E };
4
5export async function tryCatch<T, E = Error>(
6 input: (() => Promise<T>) | Promise<T>,
7): Promise<TryCatchResult<T, E>> {
8 try {
9 const promise = typeof input === 'function' ? input() : input;
10 const data = await promise;
11 return { ok: true, data, error: null };
12 } catch (error) {
13 return { ok: false, data: null, error: error as E };
14 }
15}

Callers 3

startFunction · 0.90
healthcheckFunction · 0.90
polarWebhookFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected