Last reviewed: 3/23/2024 12:01:16 PM
<catch>
A <catch> element is an event handler.
Syntax
<catch cond="expression"
count="integer"
event="event1 ..." />
Attributes
cond
An expression which must evaluate to true after conversion to boolean in order for the event to be caught. Default value is true.
count
The occurrence of the event. The count allows you to handle different occurrences of the same event differently. Default value is 1.
event
The event or events to catch. A space-separated list of events may be specified, indicating that this element catches all the events named in the list. In such a case a separate event counter is maintained for each event. If the attribute is unspecified, all events are to be caught.
Children
<assign>, <audio>, <clear>, <disconnect>, <enumerate>, <exit>, <goto>, <if>, <log>, <prompt>, <reprompt>, <return>, <script>, <submit>, <throw>, <value>, and <var>.
Parents
<field>, <form>, <initial>, <menu>, <object>, <record>, <subdialog>, <transfer>, and <vxml>.
Variables
_event
The _event shadow variable identifies the event name that caused the exception.
_message
The user-defined message from the event.
Example
The following example illustrates catching an event.
<?xml version="1.0" encoding="UTF-8"?>
<vxml xmlns="http://www.w3.org/2001/vxml"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3.org/2001/vxml
http://www.w3.org/TR/voicexml20/vxml.xsd"
version="2.0">
<meta name="author" content="VoiceXML 2.0"/>
<meta name="maintainer" content="productsupport@chant.net"/>
<form id="launch_missiles">
<field name="user_id" type="digits">
<prompt>What is your username</prompt>
</field>
<field name="password">
<prompt>What is the code word?</prompt>
<grammar version="1.0" root="root">
<rule id="root" scope="public">rutabaga</rule>
</grammar>
<help>It is the name of an obscure vegetable.</help>
<catch event="nomatch noinput" count="3">
<prompt>Security violation!</prompt>
<submit next="http://www.example.com/apprehend_felon.vxml" namelist="user_id"/>
</catch>
</field>
</form>
</vxml>
Version Information
Supported in: VoiceXML 1.0, VoiceXML 2.0, and VoiceXML 2.1.