error element

Handles errors thrown by the platform or throw element.


cond = "ECMAScript_Expression"
count = "integer"



A condition that must evaluate to true for this element to be selected by the form interpretation algorithm.


Used by the VoiceXML interpreter in the event handler selection process, allowing the developer to handle multiple occurrences of the error event in a unique manner. The default value is 1.


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


assign, audio, break, clear, data, disconnect, enumerate, exit, foreach, goto, if, log element, mark, prompt, prompt, return, script, submit, throw, value, var


The error event is shorthand for a catch element with its event attribute set to "error."

The error event handler catches error events thrown by the Platform or by the throw element.

To catch a user-defined event using the error element, prefix the name of the user-defined event with "error," for example, "error.myevent."


The following example references a non-existent external grammar file. The error event catches the error, plays a message to the user, and disconnects.

<?xml version="1.0"?>
<vxml version="2.1"
  <!-- this error handler will catch any error event in this document -->
    A fatal error occurred. Please contact a customer service representative.

    <field name="get_fruit">

      Pick a fruit

      <!-- The URI is invalid. The platform will throw error.badfetch. -->
      <grammar mode="voice" type="application/srgs+xml"
         src="http://badserver/badvroot/badfile.grammar" />


See Also

Handling Events