A while back I write about a Try – Catch construction in Microsoft Flow. Within my Catch I then sent email with some limited information such as the title of the triggering item. This is of course great to identify the item causing the error but you might want more.
Then last week I wrote about Flow Analytics and finding your failed flow. Today I’m going to take this a bit further.
Something has gone wrong in my flow and I want to get the details within my flow:
So in this case I would like to include the status, message and source returned by my failing Get Item. I generated this error by trying to get item 0 from a list in SharePoint.
“message”: “Item Not Found\r\nclientRequestId: ffe594bf-a0ee-49eb-8ec2-d5663c537fcd\r\nserviceRequestId: c7666e9e-5046-5000-bd79-d17875df57cb”,
“source”: “https:/ /mytenant.sharepoint.com//_api/SP.APIHubConnector.GetListItem(listName=’634dead0-b2c0-4a31-a11b-f548877c18ee’,itemId=’0′)”,
You could now set 3 variable with
How can we handle the flow failures while still keeping control over the flows.
I’m going to go back to my Try / catch post.
By moving my Set Variables into the Try / Catch we’re getting one step closer to where we want to be.
But now how do we handle a flow with many steps that could possible fail? We don’t just want to clutter the Scope – Catch action with a lot of actions collection the results form all potentially failing actions.
First after each potentially failing action I’m setting a variable body with the result of the action that I called. And within my Catch I’m setting the 3 variables So that I have the details of the failure.
One small problem through my catch will not happen anymore as my body is set successfully.
This is where we need to introduce the throw in flow. All I need to do is make something fail so that an error occurs and my catch will run. In my case I’m just setting an integer variable to a string value.
And now all I need to repeat is the Throw scope wherever I want to handle an error.