We use cookies

We use cookies to ensure you get the best experience on our website. For more information on how we use cookies, please see our cookie policy.

By clicking "Accept", you agree to our use of cookies.
Learn more.

User GuideOn Failure Tasks

On-Failure Tasks

The on-failure task is a special type of task in Hatchet workflows that allows you to define a function to be executed in the event that any task in the main workflow fails. This feature enables you to handle errors, perform cleanup tasks, or trigger notifications in case of workflow failures.

Defining an on-failure task

You can define an on-failure task on your workflow the same as you’d define any other task:

💡

Note: Only one on-failure task can be defined per workflow.

In the examples above, the on-failure task will be executed only if any of the main workflow task fail.

Use Cases

Some common use cases for the on-failure task include:

  • Performing cleanup tasks after a workflow failure
  • Sending notifications or alerts about the failure
  • Logging additional information for debugging purposes
  • Triggering a compensating action or a fallback workflow

By utilizing the on-failure task, you can handle workflow failures gracefully and ensure that necessary actions are taken in case of errors.