Skip to main content

Error handling

The <try /> construct is a control flow structure that handles the occurrence of errors, warnings, exceptions and other special conditions that change the normal control flow.

An error can be thrown and caught. Code may be surrounded by a <try /> statement, to facilitate the catching of potential errors. If an error is thrown or otherwise triggered within a <try /> statement, the control flow continues with the execution of the embedded CATCH statement with the error message assigned to 'var'. In case no error occurs, the control flow continues with the execution of the embedded ELSE statement instead. Eventually the control flow always continues with the execution of the embedded FINALLY statement wheter an error occurred or not.

Children

catch
XML
<catch var="var">ixml</catch>

Attributes

NameTypeDescription
varvarVariable name for error message
else
XML
<else>ixml</else>
finally
XML
<finally>ixml</finally>

Examples

Basic error handling

XML
<try>
<set var="name">iXML</set>

<if value1="$name" func="=" value2="iXML">
<error>An error has occurred!</error>
</if>

<catch var="error">
<output>$error</output>
</catch>
</try>

<!-- An error has occurred! -->

Extended error handling

XML
<try>
<set var="name">iXML</set>

<catch>
<set var="output">My name is unknown!</set>
</catch>

<else>
<set var="output">My name is $name!</set>
</else>

<finally>
<output>$output</output>
</finally>
</try>

<!-- My name is iXML! -->