An exception is an event that is performed during the execution of a program that interrupts the normal flow of instructions.
Personalized messages can be generated through this sentence. In the case of use the attributes, there will be the option of passing parameters to the message or using cataloged language messages.
1 Exception
The constructor Ax.ext.Exception is used to return an error code that is used to determine the nature of an error, and why it occurred. The code is an alphanumeric string, and localized descriptions can be registered in the table wic_js_script_messages
Ax.ext.Exception(String code) |
Ax.ext.Exception(String code, Map<String, Object> data) |
Ax.ext.Exception(String code, String message) |
Ax.ext.Exception(String code, String message, Map<String, Object> data) |
1. Ax.ext.Exception
object Ax.ext.Exception(string code, string message, object data);
Parameters | |||
---|---|---|---|
Name | Type | Required | Description |
code | string | Identifier of the exception | |
message | string | The default message when the error code is not defined or locale is not available | |
data | object | Message parameters. |
Example
Using custom message
Copy
<script type='js'> throw new Ax.ext.Exception('T00001', "Invalid month ${month}", { month: 1}); </script>
java.sql.SQLException: javax.script.ScriptException: deister.webstudio.core.jsscript.impl.lang.JSStudioException: Invalid month 1 in memory://main at line number 3 at column number 4
Example
In the following example the message is extracted from the table wic_js_script_messages, which contains the definition of the error code T00003:
Copy
// SELECT msg_code, msg_lang, msg_text FROM wic_js_script_messages WHERE msg_code = 'T00003' +------------------------------+--------+----------------------------------------+ |msg_code |msg_lang|msg_text | |char(30) |char(2) |varchar(255) | +------------------------------+--------+----------------------------------------+ |T00003 |ca |Delegació "${delega}" no trobada | |T00003 |en |Delegation "${delega}" not found | |T00003 |es |Delegación "${delega}" no encontrada | +------------------------------+--------+----------------------------------------+
Copy
<script type='js'> throw new Ax.ext.Exception('T00003', { delega: 'D-31415'}); </script>
java.sql.SQLException: javax.script.ScriptException: deister.webstudio.core.jsscript.impl.lang.JSStudioException: Delegation "D-31415" not found in memory://main at line number 3 at column number 3
Example
The following example the error thrown doesn't have a catalogued description nor a default is provided:
Copy
<script type='js'> throw new Ax.ext.Exception('T999999'); </script>
java.sql.SQLException: javax.script.ScriptException: deister.webstudio.core.jsscript.impl.lang.JSStudioException: T999999 in memory://main at line number 3 at column number 4