{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":22382,"path":"integrate-applications/use-general-try-catch.md","title":"Use the Try Catch component","bundle":null,"doc_type":null,"release":"australia","body":"\n# Use the Try Catch component\n\nCatch an error or exception that occurs in a component in an automationand transfer control to the other components within the automation.\n\n## Before you begin\n\nRole required: none\n\n## About this task\n\nTo configure the properties for the Try Catch component, see [Properties of the Try Catch component](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/integrate-applications/Properties-general-components.md).\n\nFor details on the issues related to the Try Catch component, see [KB article KB1123551](https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB1123551), [KB article KB1123552](https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB1123552), and [KB article KB1123556](https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB1123556).\n\nThe Try Catch component enables you to define which components run within the exception-handling scope and which run outside it. When an error occurs in a component within the Try scope, the component captures the exception and stops execution of the remaining components in that path. You can connect an alternative flow to the On Error port to handle the exception. Components that must run outside the exception-handling scope can be connected to the Finally port.\n\nYou can use multiple instances of the Try Catch component in an automation to handle errors from other components along the same execution path. If an activity that contains a Try Catch component calls another activity that doesn’t include the Try Catch component, the Try Catch component in the calling activity can still catch errors from the called activity.\n\n## Procedure\n\n1.  In the Toolbox pane, navigate to **General** &gt; **Try Catch**.\n\n2.  Drag the Try Catch component to the Design surface.\n\n3.  Connect the ports of the Try Catch component to the corresponding ports of the other components or activities as described in the following table.\n\n<table id=\"table_gtq_gq1_ntb\"><thead><tr><th>\n\nPort type\n\n</th><th>\n\nPort name\n\n</th><th>\n\nData type\n\n</th><th>\n\nPurpose of connection\n\n</th><th>\n\nDefault value\n\n</th><th>\n\nMandatory?\n\n</th></tr></thead><tbody><tr><td>\n\nControl Out\n\n</td><td>\n\nControl-Out\n\n</td><td>\n\nNot applicable\n\n</td><td>\n\nWhen there is no error, passes the control to another component or an activity.\n\n</td><td>\n\nNot applicable\n\n</td><td>\n\nYes\n\n</td></tr><tr><td>\n\nControl Out\n\n</td><td>\n\nOn Error\n\n</td><td>\n\nNot applicable\n\n</td><td>\n\nPasses the control to another component or activity after the Try Catch component catches an error.Use this port after the Try Catch component catches an error or exception and you want to execute another component in the current or another activity.\n\n</td><td>\n\nNot applicable\n\n</td><td>\n\nNo. Connecting the port is optional.\n\n</td></tr><tr><td>\n\nData Out\n\n</td><td>\n\nError Message\n\n</td><td>\n\nString\n\n</td><td>\n\nReturns the error message.\n\n</td><td>\n\nNot applicable\n\n</td><td>\n\nNo. Connecting the port is optional.\n\n</td></tr><tr><td>\n\nData Out\n\n</td><td>\n\nFinally\n\n</td><td>\n\nNot applicable\n\n</td><td>\n\nEnables you to execute component or activity after Try and Catch, regardless of whether an exception occurs or not.\n\n</td><td>\n\nNot applicable\n\n</td><td>\n\nNo. Connecting the port is optional.\n\n</td></tr></tbody>\n</table>4.  To test the component, right-click the component bar and then select **Run From Here**.\n\n    **Note:** The Try Catch component may not work as expected with the Parallel component.\n\n\n## Handling errors while processing an Excel file\n\nAn automation uses a **Try Catch** component when reading data from Excel. If the ReadFromExcel component fails because the file path is empty, the **Try Catch** component captures the error and displays the error message using a MessageBox. The **Finally** path then runs and displays the current date and time before the automation ends.\n\n\\[Omitted image \"Trycatch\\_2.PNG\"\\] Alt text: Example of exception handling in the Try Catch block.\n\n**Parent Topic:**[General](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/integrate-applications/general-component.md)\n\n"}}