{Step by step} Error handling in Power Automate using Try/Catch/Finally scope.

Using the Try/Catch Scope, you can create custom error messages that provide detailed information about the specific errors occurring within your flow. This can help to streamline the troubleshooting process and enable faster resolution of issues.

Requirement:

In this blog, we are generating invalid Json parameters to get the “Try” scope action failed, to demonstrate the working of the “Try/catch/Finally” scope.

Implementation:

  • Give a title to your flow.
  • Select the “Manually trigger a flow” trigger.
  • Click on “Create.”
  • Add a new action by clicking on “New step.”
  • Search for “Initialize variable.”
  • Add a name to a variable.
  • Select “String” as the type.
  • In value add an expression ‘Initial Value.’
  • Search and select the “Scope” action.
  • Add two more scope actions.
  • Rename it with “Try,” “Catch” and “Finally.”
  • Now add a “Parse JSON” action in “Try.”
  • Enter “Invalid_Json_String” in the content field.
  • And in schema add an invalid JSON.
  • Remember we are generating invalid Json parameters to get the “Try” scope action failed.
  • Add a “Set variable” action in Catch.
  • Select a variable name.
  • Enter the following expression in the value field.
  • outputs(‘Parse_JSON’)?[‘body/error/message’]
  • Select variable name.
  • Enter ‘Finally done’ in the value field.
  • Save and test the flow.
  • In this situation the “Catch” and “Finally” actions will not going to run, because of invalid parameters in the “Try” action.
  • To make it run, open the catch action menu.
  • And click on “Configure run after.”
  • Enable the “has failed” and “has timed out” options.
  • Now save and test it again.

Output:

Hope it helps! 

Power 365ing as usual! 

Any requirements, implementation or consulting work in Power Platform or Dynamics 365 – end user, Microsoft partner or an individual? 

Problem Area – Technical, Functional, Training, Development or consulting? 

Me and my team are here to assist, please fill the following form for your business needs: Click here