MCPcopy Index your code
hub / github.com/triggerdotdev/trigger.dev / try

Method try

packages/trigger-sdk/src/io.ts:1431–1444  ·  view source on GitHub ↗

`io.try()` allows you to run Tasks and catch any errors that are thrown, it's similar to a normal `try/catch` block but works with [io.runTask()](https://trigger.dev/docs/sdk/io/runtask). * A regular `try/catch` block on its own won't work as expected with Tasks. Internally `runTask()` throws som

(
    tryCallback: () => Promise<TResult>,
    catchCallback: (error: unknown) => Promise<TCatchResult>
  )

Source from the content-addressed store, hash-verified

1429 * @returns A Promise that resolves with the returned value or the error
1430 */
1431 async try<TResult, TCatchResult>(
1432 tryCallback: () => Promise<TResult>,
1433 catchCallback: (error: unknown) => Promise<TCatchResult>
1434 ): Promise<TResult | TCatchResult> {
1435 try {
1436 return await tryCallback();
1437 } catch (error) {
1438 if (isTriggerError(error)) {
1439 throw error;
1440 }
1441
1442 return await catchCallback(error);
1443 }
1444 }
1445
1446 get store() {
1447 return {

Callers 1

attachWebhookMethod · 0.80

Calls 1

isTriggerErrorFunction · 0.90

Tested by

no test coverage detected