I have a logic app, and there are 2 actions related to question.
How can i get specific error message from 1st action and use it in second (in expression)?
I noticed that there are many scenarios possible.
- Internal Server Error (500) with no message
- 4xx status code (can be with or without message)
- Action timed out and has no output (portal still says BadRequest, 3rd pic)
2
Answers
This is a flow that demonstrates what to do …
A lot of it is semantics to throw an error but the most important section is at the bottom.
Basically, within the
Scope
section, I’m setting a variable that divides an amount by 0 which, as you’d expect, throws an error.The
Initialize Error
(set as anArray
) step at the bottom reads the result information that comes out of theScope
execution. You can do this by using theresult()
expression.So in completeness, the expression within that step is …
https://learn.microsoft.com/en-us/azure/logic-apps/workflow-definition-language-functions-reference#result
… but you also need to make sure you set the behaviour of the
Initialize Error
step to actually fire after an error from that which occurs within theScope
…https://learn.microsoft.com/en-us/azure/logic-apps/logic-apps-exception-handling?tabs=consumption#change-run-after-behavior-in-the-designer
… and this is the result of that execution …
if you have more "levels" in your logic app, for example
a scope -> loop -> condition
then you need to union() the result() from each "level":
then you can filter thru this array to find what you are looking for, I use it to find Failed runs and its outputs