OpenWGA 7.3 - TMLScript reference


Object:

Error

Description This is the error object that gets thrown in JavaScript on any error occasion and can be retrieved by the catch statement.

Error objects in TMLScript mostly resemble normal JavaScript error objects of the JavaScript 1.5 Standard. The methods and properties documented here are features special to TMLScript that differ from the standard.

The differences of TMLScript error objects are caused by the fact that TMLScript is mainly dealing with Java APIs under the hood and therefor needs to be able to cope with the possibility of Java exceptions which should be handleable from TMLScript.
Retrieval By catch blocks as the parameter given in the brackets. For example: catch(e)
Allowed in script types
  • WebTML pages and normal WebTML actions
  • Master actions
  • TMLScript tasks in jobs
  • Content type events
    portletevent
Properties and methods
Name Purpose
javaException Provides an optional Java exception that caused this error
message Message of the error
Examples A standard error handling scheme in TMLScript. This script manually tests if the error contains a Java exception and logs it to the applog if so:

try {
....
}
catch (e) {
    addWarning("Error in TMLScript" + e.message, false);
    if (e.javaException) {
        log.error("Java-Exception in TMLScript", e.javaException);
    }
}


A simpler way to deal with the fact that TMLScript errors may contain Java exceptions is using the method this.logException(), which treats exceptions automatically:

try {
....
}
catch (e) {
    logException(e);
}