---
schema_version: "1"
id: fd2e1cd674ddebe778060b507ef1c87efb29e139ebad0d644dd0d00993554eb6
title: Handle Errors by Using a Try-Catch Block
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/xcloud/264-0-0/os_handle_errors_using_try_catch_blocks_49845.md
canonical_url: https://help.salesforce.com/s/articleView?id=xcloud.os_handle_errors_using_try_catch_blocks_49845.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 133bc9cd61ab3164350aaef77c8b33d85c72837579a08f413a1ee079654fc249
description: Handle errors in Integration Procedures by using Try-Catch Blocks. A Try-Catch Block lets you "try" running the steps inside it and then "catch" the error if a step fails.
products:
  - Omnistudio
release: "264"
---
# Handle Errors by Using a Try-Catch Block

Handle errors in Integration Procedures by using Try-Catch Blocks. A Try-Catch Block lets you "try" running the steps inside it and then "catch" the error if a step fails.

To set up a Try-Catch Block:

1. Drag a Try-Catch Block into the Structure panel and make sure its **Fail on Block Error** checkbox is checked.
2. Configure the "catch" behavior — what the Try-Catch Block will do if a failure occurs. You can choose one or both of these options:
    
    - Under **Failure Response**, specify a key-value pair to return as the response. The value can be a formula. In Spring '20 and later releases, the value can include merge fields.
    - Under **Custom Failure Response**, specify a Remote Class and a Remote Method to execute an Apex class. The Apex class must implement Callable.
3. Drag substeps into the Try-Catch Block, and make sure the **Fail on Step Error** checkbox is checked for each step that must trigger the "catch" behavior if it fails.
    
    You can optionally specify a **Failure Condition Formula**, which evaluates to TRUE if a specific step has failed to execute successfully.

- **[Create a Try-Catch Block Example](https://help.salesforce.com/s/articleView?id=xcloud.os_create_a_try_catch_block_example_49920.htm&release=264.0.0&type=5)**  
    An Integration Procedure creates and deletes a Contact with the specified LastName and returns an error message if the LastName is blank.
- **[Create a Try-Catch Block Example with a Formula](https://help.salesforce.com/s/articleView?id=xcloud.os_create_a_try_catch_block_example_with_a_formula_50043.htm&release=264.0.0&type=5)**  
    An Integration Procedure finds Contacts with the specified Name and returns an error message if none are found. Because returning no records normally isn't considered a failure, the Omnistudio Data Mapper Extract Action within the Try-Catch Block includes a Failure Condition Formula.