# <error>

Description

Catches error events thrown by the VoiceXML application or the IP Mediia Server platform. The `<error>` element associates an error handler with a document, dialog (i.e. form or menu), or form item. It contains executable content. It is a shorthand notation for `<catch event="error">` and catches all error events with a name whose prefix is "error". For example, `error.badfetch` and `error.grammar.asr` can be handled by this element.

Please refer to the Event Handling reference for a list of errors.

Syntax

    <error
        count="integer"
        cond="ECMAScript_Expression">
      child elements
    </error>

Attributes

Attribute | Description
count | The count attribute allows you to handle different occurrences of the same error event differently. Each form, menu, and form item maintains a counter for each error event that occurs while it is being visited; these counters are reset each time the menu or form item's form is re-entered. When there are more than one `<error>` element catching the same error event, the element in the closest scope with the highest count that is less than or equal to the current counter will be selected. Optional. (Defaults to 1.)
cond | An ECMAScript expression to be evaluated and used as a boolean condition. This `<error>` element will only catch the error if the expression evaluates to `true`. Optional. (Defaults to true.)

Anonymous Variables

Two anonymous variables are available within the scope of the `<error>` element:

- _event - This contains the name of the error event that was thrown.
- _message - This contains the message string from the corresponding `<throw>`, `<choice>`, `<link>`, or `<return>` element, or a platform defined value for error events thrown by the platform. If no message is specified, the value of this variable is ECMAScript `undefined`.

Parents

<field>, <form>, <initial>, <menu>, <object>, <record>, <subdialog>, <transfer>, <vxml>

Children

<assign>, <audio>, <clear>, <data>, <disconnect>, <enumerate>, <exit>, <foreach>, <goto>, <if>, <log>, <prompt>, <reprompt>, <return>, <script>, <submit>, <throw>, <value>, <var>, #PCDATA

Extensions

Limitations/Restrictions

- With the `com.voicegenie.STRICTCONFORMANCE` property set to `FALSE`, if an `<error>` element is in a different page (ex. application root) from the page that the error was thrown in, relative URIs in the `<error>` element are resolved relative to the page that catches the error.

Example

    <?xml version="1.0"?>
    <vxml version="2.0" xmlns="http://www.w3.org/2001/vxml">
      <error>
         An error has occurred.
         <exit/>
      </error>
      <form>
        <property name="TTSENGINE" value="NONEXISTENT"/>
        <block>
          Trying to use an invalid TTS engine will cause an error.
        </block>
      </form>
    </vxml>