An exception is an unwanted event whics happens during the execution of the script and which interrupt the normal flush of itself. Axional Studio XSQL-Script allows the use of exceptions through the sentence <try>. The use of exeptions is an improvement of the error treatment. In some cases, it is possible to avoid that the script which is being interpreted causes a error situation. When a code line causes an unexpected situation, the exception is thrown (XSQLScriptRunner creates an instance of the Exception class), which is captured, performing a set of corrective actions to restore the normal situation.

# 1 exception

For the cases in which it is not possible to prepare the statement and the system can not determine it automatically, you should indicate in the same attribute variable prepare with the value false, as for example:

<exception code='code'>    <exp /> !    <lang id='id' /> !</exception>
Example

Issuance of an error message, in an unique language.

Copy
<xsql-script name='exception_sample1'>
<body>
<null name='code' />
<if>
<expr><isnull><code/></isnull></expr>
<then>
<exception>inexisting code</exception>
</then>
</if>
</body>
</xsql-script>

The completion of the execution of the script is conditionned on if the content of the variable code is null.

Example

Issuance of an error message, depending on the user's language.

Copy
<xsql-script name='exception_sample2'>
<body>
<null name='code' />
<if>
<expr><isnull><code/></isnull></expr>
<then>
<exception>
<lang id='en'>codigo inexistente</lang>
<lang id='ca'>codi inexistent</lang>
<lang id='es'>Non-existent code</lang>
</exception>
</then>
</if>
</body>
</xsql-script>

The completion of the execution of the script is conditionned on if the content of the variable code is null. The issuance of a message or another will depend of the user's language which executes the process.