Intro

Make sure your flows can handle when things don’t go as expected: Exception Handling.

Learning Objectives

  • Exception Handling
  • JSON Parsing

Description

  • Create two number variables, A and B
  • Compose
    • Add the two variables
      • Expression: add(variables(‘A’),variables(‘B’))
  • What happens if you change B to a text?
    • Exception we need to handle
  • Create a Scope with three Scopes in
    • Try Catch
      • Try
      • Catch
      • Finally
    • Let it handle exceptions in our flow
      • “Configure run after” in the following action
  • Create a (simple) log that tells if the transaction is successful or failed
    • Initialize variable: TransactionStatus
      • Change the value accordingly in the Try and Catch
  • Create a detailed log with an error message
    • Initialize variable
      • ErrorMessageĀ 
    • In the Catch, parse the result of the Try block to get an error message
    • Parse JSON
    • Use a Condition to only write the error message if there is an error
  • Create an Excel sheet with multiple transactions and create exception handling (advanced, you can watch the video below)

Hints

  • Two main exception types:
    • System Exception
      • An exception in our system, e.g., a program that won’t open
    • Business Exception
      • An exception in our data, e.g., a missing social security number in one of our data records
  • Use a Parse JSON and the following expression to get the error message:
    • body(‘Parse_JSON_Try_Error_result’)[0][‘error’]?[‘message’]