MCPcopy Create free account
hub / github.com/api3dao/airnode / runAndHandleErrors

Function runAndHandleErrors

packages/airnode-examples/src/cli.ts:11–24  ·  view source on GitHub ↗
(fn: () => Promise<unknown>)

Source from the content-addressed store, hash-verified

9 * Any uncaught error or promise rejection will be printed out in the console.
10 */
11export const runAndHandleErrors = (fn: () => Promise<unknown>) => {
12 const goFn = goSync(() =>
13 fn()
14 .then(() => process.exit(0))
15 .catch((error) => {
16 cliPrint.error(error);
17 process.exit(1);
18 })
19 );
20 if (!goFn.success) {
21 cliPrint.error('' + goFn.error);
22 process.exit(1);
23 }
24};
25
26/**
27 * Run the command passed as an argument in the current shell and stream the output of the command in the CLI.

Calls

no outgoing calls

Tested by

no test coverage detected