---
title: Do Try
description: Learn how to use EIPs
documentId: ipaas-eips-dotry
locale: en-US
---

<Callout type="important" title="IMPORTANT">
If any EIP configuration is not available in the form, you can adjust it directly in the main.yaml file. To do so, access the **Source Code** tab and edit the integration code.
</Callout>

The **Do Try** EIP allows you to create integration flows involving a process in a **Try** block. It creates **Do Catch** and **Do Finally** branches to handle specific exceptions and ensure that certain actions are executed at the end, regardless of errors.
With this, failures can be handled in a controlled manner, ensuring that the flow execution continues without unnecessary interruptions.

## Configuring the Do Try EIP in the Diagram

To configure a **Do Try** in an integration in the **Diagram** tab, follow these steps:

<Steps>
<Step>
Click **+Add Step** on the canvas.
</Step>
<Step>
Select the **EIPs** tab.
</Step>
<Step>
Select the **Do Try EIP**. You can use the search tool to locate it.
</Step>
<Step>
When adding the EIP to the canvas, three branches will be automatically created:

* **Empty step**: by clicking **Add Step**, you add the EIP or component that will continue the flow. Only one branch of this type is allowed in the Try block.
* **Do Catch**: captures and handles specific exceptions that may occur within the Try block. If there are multiple Do Catch blocks, it executes the exception that is captured first.
  * You can insert one or more exceptions in the **Exception** field.
* **Do Finally**: this block is always executed, regardless of whether an exception occurred or not (even if there is no Do Catch block). The Do Finally branch will always be the rightmost one. Only one Do Finally branch is allowed for each Do Try EIP.
</Step>
</Steps>

<Callout type="note" title="NOTE">
You can add other Do Catch type branches by clicking "+" and then **Add Handling Step**.
</Callout>

## Deletion of the Do Try EIP and its branches

There are three deletion scenarios for the Do Try EIP and its branches:

* When deleting a **Do Catch** block, all steps in that branch will be removed.

* When deleting a **Do Finally** block, all steps in that branch will be removed.

* When deleting a **Do Try EIP**, all blocks and subsequent steps will be removed.

## Example

![](https://creative-ball-51b3fc85c0.media.strapiapp.com/example_dotry_26c0ebf4c4.png)

<Steps>
<Step>
The flow starts with a timer, which is triggered every 60 seconds to query orders from an ERP.
</Step>
<Step>
The flow attempts to access the ERP to get orders and process them with **Do Try**.
The order is then sent directly to the financial system and the status is updated in the ERP.
</Step>
<Step>
If there are connection errors, such as `ConnectException` or `SocketTimeoutException`, these errors will be captured with **Do Catch**, logged, and a notification will be sent to the IT team.
</Step>
<Step>
Regardless of whether the flow was successful or failed, the integration process will be finalized with an audit record and a log generation with **Do Finally**.
</Step>
</Steps>

Check the example in code format:

```yaml
- from:
    uri: timer:ConsultOrder
    parameters:
      period: 60000
    steps:
      - doTry:
          id: doTry
          steps:
          - to: "http://erp.example.com/api/orders"
          - log:
              message: "Orders received: ${body}"
          - setBody:
              simple: "Processed orders: ${body}"
          - to: direct:sendToFinance
          - to: direct:updateERPStatus
          doCatch:
            - id: doCatch
              exception:
                 - java.net.ConnectException
                 - java.net.SocketTimeoutException
              steps:
                - log:
                    message: "Failed to access ERP: ${exception.message}"
                    loggingLevel: ERROR
                - to: direct:notifyError
          doFinally:
            id: doFinally
            steps:
              - log:
                  message: "Finalizing integration process - auditing"
              - to: direct:registerAudit
```
