Zum Hauptinhalt springen

Error handling

Description: 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

Anatomy of Error triggered execution

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

Attributes:

NameTypeDescription
varvarVariable name for error message
else

Anatomy of Elsewise execution

<else>ixml</else>
finally

Anatomy of Final execution

<finally>ixml</finally>

Examples

Basic error handling

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

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

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

<!-- An error has occured! -->

Extended error handling

<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! -->