Please enable JavaScript to view this site.

Altova MobileTogether Designer

» No topics above this level «


Scroll Home Prev Top Next More

The Try/Catch action has two parts (highlighted in the screenshot below):


Try: Defines a condition or an action to try.

ϖA condition is defined in the XPath expression of a Throw action. (See the Sharing Geolocations tutorial for an example of using the Throw action.)

ϖIf an action is defined (such as the Execute REST Request action in the screenshot below) and an error is detected while executing the action, then you can choose from among the following options: (i) abort the action; (ii) ignore the error and continue; or (iii) throw an exception that is stored in the Try/Catch action's variable; this is the Throw option. (Even if you choose to continue (the second option), you can still throw an error by using the Throw action.)

ϖBoth the Throw action (defined for a condition) or the Throw option (defined for an action) each throw an exception that is stored in the Try/Catch action's variable.

Catch: Defines actions to execute if, and only if, an exception is thrown (see the description of the screenshot below). If no Catch action is defined, then the action that follows the Try/Catch action is processed.


Note: Exceptions can be thrown in two ways: via a Throw action (defined for a condition) and via a Throw option (defined for an action).


Note:If an exception is thrown, it is stored in the variable of the Try/Catch action, and the Catch part will be executed.


Note:        If no exception is thrown in the Try part of the action (by the Throw action/option), then the Catch part is not executed.


In the Try/Catch action shown in the screenshot above, we have done the following:


1.We have given the Try/Catch variable a name of $SomeVar (by double-clicking to the right of the $ symbol, and entering the name).

2.In the Try part of the action, we have set up the Execute REST request.

3.In the Try part of the action, we have selected the Throw option for the On Error sub-action of the Execute REST request, and entered an exception message as the option's XPath expression. As a result, if an error is detected, an exception is thrown and the exception message is stored in the $SomeVar variable.

4.In the Catch part of the action, we have defined a Message Box action to show the message that is stored in the $SomeVar variable.


Note:Besides the Throw option described above, a Throw action is also available. Instead of using the Throw option of the On Error sub-action (as described in Step 2 above), you could use the Continue option and insert a Throw action in the Continue option's On Error sub-action.


The tutorial Sharing Geolocations shows how the Try/Catch and Throw actions can be used.


© 2015-2021 Altova GmbH