IO
io.try()
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().
A regular try/catch
block on its own won’t work as expected with Tasks. Internally runTask()
throws some special errors to control flow execution. This is necessary to deal with resumability, serverless timeouts, and retrying Tasks.
How to catch
errors inside run()
You have two options:
- Use the
io.try()
function documented on this page. - Use a regular
try/catch
block and isTriggerError to check if the error is a special error type.
Parameters
The code you wish to run
This will be called if the Task fails. The callback receives the error
Returns
A Promise that resolves with the returned value or the error
Was this page helpful?