It is pretty standard that when a Logic App fails, we want to get the exact error message describing why it failed. But, of course, we can always go to the Logic App run history – except if it is a Stateless workflow on Standard – to check where and why it failed. And obviously, we will have all the information necessary to solve the problem.
However, most of the time, if not always, we want to log the error in some place like Application Insights, SQL Database, Event Hubs, etc. To accomplish that, we need to access this error message at runtime.
📝 One-Minute Brief
Learn how Logic Apps handle errors inside Try, Catch, and Finally scopes and how to extract detailed error messages at runtime. This guide shows how to structure Try‑Catch flows using Scopes and Configure run after settings so you can log failures to Application Insights, SQL, Event Hubs, or other systems—making your workflows more resilient and diagnosable.
As I explained in one of my Logic App Best Practices, Tips and Tricks: Error handling… configure run after settings. To implement advanced error-handling capabilities, such as:
- Creating a try-catch statement consisting of a try block followed by one catch clause to handle different exceptions that can occur in the try block.
- Or creating a try-catch-finally statement.
We have to use a combination of different Scopes.
The try-catch-finally statement handles all of the errors that may occur in a block of code. Errors can be coding errors made by the programmer, errors caused to incorrect input, and other unforeseeable factors.
- The try statement allows you to define a block of code to be tested for errors while it is being executed –> this will be your Actions inside Logic App that describe the logic of your business process.
- The catch statement allows you to define a block of code to be executed if an error occurs in the try block –> this will be your Actions inside Logic App that you want to run if some failure occurs in the standard actions of your business process.
- The finally statement lets you execute code after try and catch statements, regardless of the result (if there was a failure inside the try statement or if everything was completed successfully).
To implement a try-catch or try-catch-finally statements we need to:
- Add a Scope, we can call it Try-Scope, and add all the actions that you want to control errors inside this scope.

- Just immediately after the Try-Scope action, add a new Scope, which we can call Catch-Scope, and add all the actions necessary to perform in case of errors, like rollback actions or logging actions.

- Now, on the Catch-Scope action, click on the … (3 dots) and select Configure run after option
- Click on the Try-Scope to present the run-after options and select:
- has failed.
- has timed out.
- Note: unselect the is successful option.

- and click Done.
Now, inside the catch scope, we will have an action that logs the error, but before I call it, I need to get the detailed error message. Something similar to the e.Message that we have on our C# code.

To do this, we first need to filter the run action status results for failed items. For that, the Logic App runtime has a Workflow function call result that is able to return the inputs and outputs from the top-level actions inside the specified scoped action, such as For each, Until, and Scope. So, inside our Catch Scope, add the following action:
- Inside the Catch scope, select Add an action.
- In the search box, enter Filter array, and from the result panel, select the Data Operations, Filter array action.

- And provide the following information:
- On the From property, place the following expression:
- result(‘Try_scope’)
- Note: that ‘Try_scope? is the name of the previous scope, so you need to adjust this value to your scenario.
- On the condition, in the left textbox, place the following expression:
- item()?[‘status’]
- Note: this is always equal.
- Leave the operator as is, equal to, and in the right textbox, place the following value:
- Failed
- On the From property, place the following expression:

Because this only returns the results of the top-level actions, we want to grab the first error reported there. To do that, we need to, for example, set a variable to the error message from the previous action’s output.
- Assuming that we already have a variable initialized. Select Add an action.
- In the search box, enter Variables, and from the result panel select the Variables, Set variable action.
- On the variable shape, select the variable we want to use, and on the value, set the following expression:
- first(body(‘Filter_array’))?[‘error’][‘message’]

This is a simple approach that you can use for simple and straightforward processes that don’t contain conditions or loops, something similar to this:

However, if you are creating more enterprise processes, they will be more complicated, and we normally have nested conditions, conditions inside the loops, and so on. In those cases, this approach will not work. For example, in this scenario:

We would expect, and we want to get the error where it indeed happens – marked this with the arrow on the picture. However, what we get is the top-level action description:
- ActionFailed. An action failed. No dependent actions succeeded.
Of course, this is not what I intend. Stay tuned because I will explain how to get the correct error message in the second part of this blog post.
Hope you find this helpful! If you liked the content or found it useful and would like to support me in writing more, consider buying (or helping to buy) a Star Wars Lego set for my son.
1 thought on “How to get the Error Message with Logic App Try-Catch (Part I)”