How to throw an exception in Logic Apps - made simple

One of the features that are missing in Logic Apps (there is an idea posted since 2017) is the ability to throw an exception. What is currently available is the ability to Termine the flow, but that won't work if you are executing a parallel branch as it will finish it too. In order to workaround this, I have thought a very simple way to intentionally produce an exception. For this you can pick whatever connector and call it in a wrongly manner. For example: SQL connector executing an store procedure that doesn't exist. The above example I have used in the past and work very well, however, it makes you configure an connection to an existing SQL DB. Hence, to bringe this approach to a general escenario I have test it with an HTTP request node, which doesn't require connections at all. In order to our approach to work we need to meet two properties: 1. Whatever we use the connector the exception needs to be thrown in the 100% of the times. 2. We cannot introduce a delay on the flow. Fow example: An exception thrown because of a timeout is not desireble. To meet the above, I have configured the HTTP request node using the URI http://127.0.0.1 which is the loopback and with 100% certainty that socket will be closed - if you are more paranoic just randomize the URI-. Also the connector has the restriction to not use that address.
To really test this scenario, let's enclose it on a scope:
After running the flow we see that the scope that manages the exception is triggered.

Comments

Popular posts from this blog

Telemetry and Monitory with Applications Insights and Dynamics 365 F&O

Creating a DMF data package from files stored in an Azure blob storage