`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>
)
| 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 { |
no test coverage detected