OpenWGA 7.0 - Updating to OpenWGA 7.0

Updating from OpenWGA 6.0 » To consider before updating » Changed behaviour

TMLScript: Errors in called actions are passed on to the caller

Up until OpenWGA 6.1 a WebTML action that was called by another script would not pass back uncatched errors to the caller. An error, thrown inside a called WebTML action and not catched by a try/catch block there, would be caught by the call itself. The calling script, action or not, would have no indication that the action failed and could continue normally. The operations that follow the action however are often only meaningful if the action actually performed normally.

Therefor in OpenWGA 7.0 on a calling action will throw an error back to its caller. The action calling method (WGA.callAction()Design.callAction() or any legacy ways to do the same) will itself throw the original error object inside the calling script. The error will behave normally from there on, meaning that it can be catched by any try/catch block. If the current script is again a called action it would also pass on that error to its caller, provided it is not catched on the way.

This may change the behaviour of existing scripts, which currently continue to run after an error in a called action, and now will fail completely. However we think that in most cases this prevents the error from causing additional damage done by subsequent operations which should not run after the error.

See the following action code for a clarification about the impact:

<tml:action id="masterCreateDoc" master="true">

  var newDoc = db().getArea("contents").createRootPage(db().getContentType("standard"), "New Document");

  return newDoc.getContentKey();

</tml:action>


<tml:action id="createDoc">

  var docid = WGA.callAction("masterCreateDoc");

  portlet.setMode("edit");

  portlet.setContext(context("docid:" + docid));

</tml:action>

Imagine action "createDoc" would be called from within a portlet. The following happens if everything runs normally:

  • Action "createDoc" calls action "masterCreateDoc", a master action which has the rights to create new documents for all users
  • Action "masterCreateDoc" creates a new page in area "contents" and in default language. It then returns the content key of the new pages content document.
  • Action "createDoc" receives the content key. It then changes the mode of the current portlet to "edit" and sets its context to the new document. Apparently it wants the portlet to provide some editing UI for the new document.

Now imagine that the document creation in "masterCreateDoc" fails, maybe because area "contents" or the content type "standard" does not exist, or maybe because the connection to the backend database currently is faulty. An error is thrown, but in OpenWGA 6.0 it would be catched by the internals of WGA.callAction(). The action "createDoc" would again continue, the portlet mode would be set to "edit" and it would at least try to set the context. The UI would change but there would be no document to edit. The portlet therefor is in an invalid state.

In OpenWGA 7.0 the error would again be thrown by the call to WGA.callAction("masterCreateDoc") inside action "createDoc". All subsequent operations would be bypassed and the action call fails with an error. Also the portlet mode and context remain untouched. The portlet is kept in a consistent state.