An exception is an event, which occurs during the execution of a program, that disrupts the normal flow of the program's instructions.
1 Exception
It is possible to define various types of exception
1.1 Standard exception
it is recommended to avoid this type of exception.
Copy
<xsql-script> <body> <exception>THIS IS A EXCEPTION.</exception> </body> </xsql-script>
XSQLScriptException[THIS IS A EXCEPTION.]
Copy
throw new Exception("ESTO ES UNA EXCEPCIÓN");
Error: ESTO ES UNA EXCEPCIÓN.
1.2 Encoded exceptions
If the script is cataloged in wic_xsql_script and the TEST1
exception code is defined in the wic_xsql_script_messages table, for this script in
the language that the user uses in his session. The text that is registered in
wic_xsql_script_messages will be displayed. Otherwise THIS IS AN EXCEPTION
The text that is registered in wic_js_script_messages
will be displayed. Otherwise THIS IS AN EXCEPTION.
Copy
<xsql-script> <body> <exception code='TEST1' message='ESTO ES UNA EXCEPCIÓN.' /> </body> </xsql-script>
XSQLScriptException[ESTO ES UNA EXCEPCIÓN.]
Copy
throw new Ax.ext.Exception('TEST1', "ESTO ES UNA EXCEPCIÓN");
java.sql.SQLException: deister.axional.server.jdbc.exception.ScriptExceptionInfo: ESTO ES UNA EXCEPCIÓN
We can add parameters in the message, both the default and those registered
in wic_xsql_script_messages. By preference we always try to get the one from wic_xsql_script_messages.
We can add parameters to the message, both the default and those registered in
wic_js_script_messages. By preference we always try to get the one from wic_js_script_messages. THIS IS
AN EXCEPTION. MESSAGE1: [text1], MESSAGE2 [text2]
Copy
<xsql-script> <body> <exception code='TEST2' message='ESTO ES UNA EXCEPCIÓN. MENSAJE1: [{0}], MENSAJE2 [{1}]'> <arg><string>TEXTO1</string></arg> <arg><string>TEXTO2</string></arg> </exception> </body> </xsql-script>
XSQLScriptException[ESTO ES UNA EXCEPCIÓN. MENSAJE1: [TEXTO1], MENSAJE2 [TEXTO2]]
Copy
throw new Ax.ext.Exception( 'TEST1', "ESTO ES UNA EXCEPCIÓN. MENSAJE1: [${eStrTxt1}], MENSAJE2 [${eStrTxt2}]", { eStrTxt1 : 'texto1', eStrTxt2 : 'texto2' });
java.sql.SQLException: deister.axional.server.jdbc.exception.ScriptExceptionInfo: ESTO ES UNA EXCEPCIÓN. MENSAJE1: [texto1], MENSAJE2 [texto2]
If we use 'instead of quotes'. In case there is no record in wic_js_script_messages The variables registered in the
JS itself will be shown, not the ones that we are passing by parameter. The following definition in case of not having
a registry defined in wic_js_script_messages, will produce an exception of the type
ReferenceError: "eStrTxt1" is not defined
Copy
throw new Ax.ext.Exception( 'TEST2', `ESTO ES UNA EXCEPCIÓN. MENSAJE1: [${eStrTxt1}], MENSAJE2 [${eStrTxt12}]`, { eStrTxt1 : 'texto1', eStrTxt1 : 'texto2' });
java.sql.SQLException: deister.axional.server.jdbc.exception.ScriptExceptionInfo: ReferenceError: "eStrTxt1" is not defined
In this case there is no default text. If there is no record
in wic_xsql_script_messages. TEST3 will be displayed
In this case there is no default text. If there is no record
in wic_js_script_messages. TEST3 will be displayed
Copy
<xsql-script> <body> <exception code='TEST3' /> </body> </xsql-script>
XSQLScriptException[TEST3]
Copy
throw new Ax.ext.Exception('TEST3');
java.sql.SQLException: deister.axional.server.jdbc.exception.ScriptExceptionInfo: TEST3
Initialization with arguments without default value is also accepted.
Copy
<xsql-script> <body> <exception code='TEST4'> <arg><string>TEXTO1</string></arg> <arg><string>TEXTO2</string></arg> </exception> </body> </xsql-script>
XSQLScriptException[TEST4]
Copy
throw new Ax.ext.Exception( 'TEST4', { eStrTxt1 : 'texto1', eStrTxt1 : 'texto2' });
java.sql.SQLException: deister.axional.server.jdbc.exception.ScriptExceptionInfo: TEST4