How to Add Error Handling to a Flow and Continue Execution When an Error Occurs
Tags: nocode, workflows, okta, ipaas
Published: 2022-08-29 17:48:21

---
title: How to Add Error Handling to a Flow and Continue Execution When an Error Occurs
published: true
date: 2022-08-29 05:26:26 UTC
tags: NoCode, Workflows, Okta, ipaas
canonical_url: https://maxkatz.net/2022/05/06/how-to-add-error-handling-to-a-flow-and-continue-execution-when-an-error-occurs/
---

[Okta Workflows](https://www.okta.com/platform/workflows/) how-to guides are questions and answers from weekly community [office hours](https://calendly.com/oktaworkflows/group-office-hours-okta-workflows), MacAdmins [Workflows Slack channel](https://www.macadmins.org), and other places. 

Read all previous how-to guides ⤵️
{% embed https://dev.to/oktaworkflows/all-okta-workflows-how-to-guides-4nl9 %}

On to the question.

**_How to add error handling to a flow and continue execution when an error occurs?_**

When a card execution fails, the flow execution will stop. Any cards after the error card will not be executed.

For example, in the screenshot below, API call fails, the flow stops executing and the **Assign** card is not processed.

[![Card execution error](https://katzmax.files.wordpress.com/2022/05/workflows_howto_error1.png?w=1006)](https://katzmax.files.wordpress.com/2022/05/workflows_howto_error1.png)
<figcaption>Card execution error</figcaption>

Another example where flow execution stops is when **Read User** card results in an error (when providing an invalid user ID).

[![Card execution error](https://katzmax.files.wordpress.com/2022/05/workflows_howto_error_readuser.png?w=1024)](https://katzmax.files.wordpress.com/2022/05/workflows_howto_error_readuser.png)
<figcaption>Card execution error</figcaption>

You want to be able to gracefully handle the error and continue the flow execution. To do that use the **Error Handling – If Error** card.

The **If Error** card has two sections: **Try** and **If Error**. You will try something and if it fails, the if error logic will be called and will allow you to continue the flow execution.

Using the API example from above, this is how the **Try** section looks. You place cards inside the **Try** section.

[![If Error card – Try section](https://katzmax.files.wordpress.com/2022/05/workflows_howot_error_try_api2.png?w=1024)](https://katzmax.files.wordpress.com/2022/05/workflows_howot_error_try_api2.png)
<figcaption>If Error card – Try section</figcaption>

This is how the **If Error** section looks. You add any cards to process the error.

[![If Error card – section to handle error](https://katzmax.files.wordpress.com/2022/05/workflows_howto_error_iferror_api2.png?w=1024)](https://katzmax.files.wordpress.com/2022/05/workflows_howto_error_iferror_api2.png)
<figcaption>If Error card – section to handle error</figcaption>

The **If Error** card allows to define output. Based on which path is taken, the **Number** will be set to either **100** or **-100**.

> **Tip** : Learn how to [create outputs](https://dev.to/maxkatz/workflows-tips-18-access-all-user-properties-output-for-ifelse-condition-and-partial-user-update-371g-temp-slug-9813454) for an If/Else card

> **How-to Guide** : [How to Handle an External API Call Error in Workflows](https://dev.to/maxkatz/how-to-handle-an-external-api-call-error-in-workflows-1729-temp-slug-3830128)

If the flow generates an error, the **If Error** card handles the error and the flow execution continues. The **Assign** card outside of **If Error** was processed.

[![Flow execution continues after an error](https://katzmax.files.wordpress.com/2022/05/workflows_howto_error_tryapi_run.png?w=1024)](https://katzmax.files.wordpress.com/2022/05/workflows_howto_error_tryapi_run.png)
<figcaption>Flow execution continues after an error</figcaption>

In the same way you can place **Read User** inside the **Try** section of **If Error** card.

[![If Error card – Try section](https://katzmax.files.wordpress.com/2022/05/workflows_howto_error_readuser_try.png?w=1024)](https://katzmax.files.wordpress.com/2022/05/workflows_howto_error_readuser_try.png)
<figcaption>If Error card – Try section</figcaption>

[![If Error card – section to handle error](https://katzmax.files.wordpress.com/2022/05/workflows_howto_error_readuser_error.png?w=1024)](https://katzmax.files.wordpress.com/2022/05/workflows_howto_error_readuser_error.png)
<figcaption>If Error card – section to handle error</figcaption>

Even though the **Read User** cards results in an error the flow execution continues. The **Assign** card outside of **If Error** was processed.

[![Flow execution continues](https://katzmax.files.wordpress.com/2022/05/workflows_howto_error_readuser_run.png?w=1024)](https://katzmax.files.wordpress.com/2022/05/workflows_howto_error_readuser_run.png)<figcaption>Flow execution continues </figcaption>

* * *

💎 Read all other [Okta Workflows How-To Guides](https://maxkatz.net/okta-workflows-how-to-guides/).

📒 Have a question about Okta Workflows? Join the weekly community [office hours](https://calendly.com/oktaworkflows/group-office-hours-okta-workflows) to get help.