Try Catch

Catches an exception raised in the activities in the Try section and runs the Catch section that matches the exception type. Optionally, a Finally section that runs at the end is added.


Usage

A Try Catch added from the toolbox has a Try section and a Catch section of type System.Exception.

  • Try: The activities to run are added here.

  • Catch: Its header shows the exception type it catches; the type is changed by clicking it. The list contains System.Exception, PAWRobot.BusinessRuleException, PAWRobot.Interfaces.ElementNotFoundException, System.ArgumentException, System.NullReferenceException, System.IO.IOException and System.InvalidOperationException; another type is selected with Browse.... A second Catch section cannot be added for the same type.

  • In this section the caught exception is accessed through Exception Name (default exception, e.g. exception.Message). When a Catch section is selected, the Exception Type and Exception Name fields appear in the properties panel.

  • Finally: Runs after the Try section and (if an exception was caught) the corresponding Catch section have finished. There can be at most one.

  • The Add (+) button in the section header opens the Add Catch and Add Finally commands; the Delete button deletes the section. Catch sections are reordered by dragging.

Exception matching:

  • An exception goes to the Catch section whose type is exactly the same; if there is no such section, it goes to the section with the most specific type that covers the exception type. Therefore the order of the Catch sections does not change the result.

  • If no Catch section matches, the exception is passed out of Try Catch. A Try Catch with only a Finally section does not catch the exception either.

  • If there is neither a Catch nor a Finally section, the exception in the Try section is ignored and the flow continues after Try Catch.

  • To pass the caught exception out again, Rethrow is used in the Catch section.