Error handling

Generally, when an error occurs during the execution of a CCXML document, the corresponding error event is added to the front of the document’s event queue, causing the CCXML application to process the error immediately after the current event. Errors occurring during initialization of a CCXML document, or in eventprocessor elements are identified by the CCXML Browser and the execution of the CCXML document is terminated immediately.

To handle error conditions that can arise during a telephone call, your CCXML document must use a <transition> element to process each type of error event. Your CCXML application can record the error events by using a <log> element for each error event.

For example, to log a connection.disconnected event:
<transition event="connection.disconnected" name="evt">
	<log expr="'Call '+evt.connectionid+ 'has been disconnected'"/>
</transition>
The expr attribute of the <log> element is used to define the text of the message to log. In this example the connectionid identifying the telephone call is included as a variable within the message.

Using a wildcard transition to catch and log any unexpected events

If an event does not have a matching transition, the CCXML Browser discards that event and moves to the next event in its queue. This can result in errors or information events being missed. Therefore, when developing and debugging a CCXML document, it is often useful to have a wildcard transition at the end of the document to catch any events that are not handled by other transitions.

To create a general ‘catch all’ error trap, use an * ‘wildcard’ in the event attribute:

<transition event="error.*" name="evt">
	<log expr="'Received '+evt.name+ ' with reason ' +evt.reason"/>
</transition>

The expr attribute of the <log> element is used to define the text of the message to log. In this example the name and reason are included as variables within the message, which resolves to a printable error message associated with the error.

See also: