OpenWGA 7.11 - TMLScript reference

Method :

logException([msg, ] error)

On object WGA
Usage Logs a JavaScript exception as WebTML warning and in application log
Description This is a convenience method to cope with unexpected exceptions in TMLScript code, so that they are logged and can be analyzed.

All exceptions in JavaScript at first are JavaScript Errors but their cause may be a real JavaScript failure or a wrapped Java exception, which is tedious to test. This method copes with both cases and tries to log all information that is available in the situation:
  • If the cause is an JavaScript error it is put out only as WebTML warning
  • If the cause is a Java exception it logs some error information as WebTML warning. A whole stack trace is logged to the application log
For backward compatibility there still is a global function "logException()" available whose use is discouraged since OpenWGA 5.3.
Parameters msg (String, Optional): A message that is put out with the error

error: An Error object like it is thrown in TMLScript.
Allowed in script types
  • WebTML pages and normal WebTML actions
  • Master actions
  • TMLScript tasks in jobs
  • Content type events
Examples The following code template may be used in all TMLScripts with longer/more complicated operations, which may throw unexpected errors. The whole procedure is wrapped in a try/catch block. In the catch block the caught error is logged via logExcepion():

try {
    ...."Process finished");
catch (e) {
    WGA.logException("Process ended with error", e);