Throw
The Throw action is intended to be used in the Try part of a Try/Catch action (see screenshot below). It evaluates an XPath expression. If the result of the evaluation is not an empty sequence, then an exception is thrown, and the exception is stored in the variable of the Try/Catch action; in the screenshot below, this variable is named $Not-USA-Warning.
In the example shown in the screenshot above, we throw an exception if the geolocation of the device is not in the USA. The XPath expression is:
if ($MT_GEOLOCATION/Root/Address/@CountryName != 'USA')
then (concat( 'Warning: Device location is outside the US: ', $MT_GEOLOCATION/Root/Address/@CountryName))
else ()
This expression works as follows:
•The if clause checks whether the value of the $MT_GEOLOCATION/Root/Address/@CountryName node is (not) 'USA'.
•The then clause is processed if the country name is not USA. This clause generates a string.
•The else clause is processed if the country name is USA. It produces an empty sequence
If the geolocation country is not USA, then the condition is true and the expression evaluates to the string generated by the then clause. Since this result is not an empty sequence, an exception is thrown and the generated string is stored in the Try/Catch variable $Not-USA-Warning.
If the geolocation country is USA, then the condition is false and the expression evaluates to an empty sequence (generated by the else clause). Because the result is an empty sequence, no exception is thrown. Therefore, the Catch part of the Try/Catch action is not executed.
Note: | If a sequence contains an empty string item (''), then the sequence is not empty (and an exception will be thrown). |
The tutorial Sharing Geolocations shows how the Try/Catch and Throw actions can be used.
MobileTogether extension functions
MobileTogether provides a range of XPath extension functions that have been specifically created for use in MobileTogether designs. Some functions can be particularly useful with specific actions. For example, mt-available-languages() returns the languages in which the solution is available and could, for example, be used with the Message Box action. If a function is especially relevant to this action, it is listed below. For a full list of extension functions and their descriptions, see the topic MobileTogether Extension Functions.