> For the complete documentation index, see [llms.txt](https://docs.plumvoice.com/dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.plumvoice.com/dev/voicexml/tags/catch-tag.md).

# \<catch>

## \<catch> <a href="#catch" id="catch"></a>

The \<catch> element associates a catch with a document, dialog, or form item. This element is a specific type of XML Events handler that acts as an observer of its parent element. It contains executable content.

### Attributes

<table><thead><tr><th width="164.33333333333331">Name</th><th width="166">Data type<select><option value="34decfe2ca994aaa9fcfb85c6a3aa484" label="String" color="blue"></option><option value="c6a8b0cd09e2449f801736c0782b290d" label="Integer" color="blue"></option><option value="de5f92fc3abe432aac0846fe9adb2ffe" label="Boolean" color="blue"></option></select></th><th>Description</th></tr></thead><tbody><tr><td>event</td><td><span data-option="34decfe2ca994aaa9fcfb85c6a3aa484">String</span></td><td><p>The event or events to catch.</p><p></p><p>A space-separated list of events may be specified, indicating that this &#x3C;catch> element catches all the events named in the list.</p><p></p><p>In such a case, a separate event counter (see “count” attribute) is maintained for each event. If the attribute is unspecified, all events are to be caught.</p></td></tr><tr><td>count</td><td><span data-option="c6a8b0cd09e2449f801736c0782b290d">Integer</span></td><td><p>(defaults to 1) The occurrence of the event. The count allows you to handle different occurrences of the same event differently.</p><p></p><p>Each &#x3C;form>, &#x3C;menu>, and form item maintains a counter for each event that occurs while it is being visited; these counters are reset each time the &#x3C;menu> or form item's &#x3C;form> is re-entered.</p><p></p><p>The form-level counters are used in the selection of an event handler for events thrown in a form-level &#x3C;filled>. Counters are incremented against the full event name and every prefix matching event name. </p><p></p><p>For example, occurrence of the event “event.foo.1” increments the counters associated with handlers for “event.foo.1” plus “event.foo” and “event”.</p></td></tr><tr><td>cond</td><td><span data-option="34decfe2ca994aaa9fcfb85c6a3aa484">String</span></td><td>(defaults to true) An expression that must evaluate to true after conversion to Boolean in order for the event to be caught.</td></tr></tbody></table>

### Notes

The `<error>`, `<help>`, `<noinput>`, and `<nomatch>` elements are shorthand for types of `<catch>` elements.

### Example

```markup
<?xml version="1.0"?>
<vxml version="2.0">
  <form>
    <field name="customer_id" type="digits?length=5">
      <prompt>
        Please enter your customer identification number.
      </prompt>
      <filled>
        <prompt>
          Thank you.
        </prompt>
        <!-- submit to a script that doesn't exist -->
        <submit next="process_customer.php" namelist="customer_id"/>
      </filled>
      <catch event="nomatch noinput" count="1">
       <!-- this code executes for count 1 and 2, the FIA looks at all of the matching <catch> elements and finds the highest count value that is <= the current count-->
        <prompt>
          Your input was not valid. Your customer identification number is the five digit number on your membership card.
        </prompt>
        <reprompt/>
      </catch>
      <catch event="nomatch noinput" count="3">
        <prompt>
          It seems you are having difficulty with your customer identification number. Please call the number on the back of your membership card. Goodbye.
        </prompt>
        <exit/>
      </catch>
      <catch event="error.badfetch">
        <prompt>
          I'm sorry, it appears we are having technical difficulties. Please try your call again later.
        </prompt>
        <exit/>
      </catch>
    </field>
  </form>
</vxml>
```

The catch tag can be used to catch application level errors, such as when the IVR attempts to fetch a script that doesn't exist (error.badfetch) or the user hangs up (error.disconnect.hangup).

The following is a scenario where the user enters a valid 5 digit number:

> Computer: Please enter your customer identification number.\
> User: \<enters 1 2 3 4 5>\
> Computer: Thank You. (attempts to fetch process\_customer.php, which does not exist) \<catch: error.badfetch>\
> Computer: I'm sorry, it appears we are having technical difficulties. Please try your call again later. \*application hangs up\*<br>

The catch tag can also be used to define custom nomatch and noinput events.\
The following is a scenario where the user does not enter any input:

> Computer: Please enter your customer identification number.\
> User: \<silence: user enters nothing> \<noinput x1>\
> Computer: Your input was not valid. Your customer identification number is the five digit number on your membership card.\
> Computer: Please enter your customer identification number.\
> User: \<silence: user enters nothing> \<noinput x2>\
> Computer: Your input was not valid. Your customer identification number is the five digit number on your membership card.\
> Computer: Please enter your customer identification number.\
> User: \<silence: user enters nothing> \<noinput x3>\
> Computer: It seems you are having difficulty with your customer identification number. Please call the number on the back of your membership card. Goodbye. \*application hangs up\*

### Child Tags

[\<audio>](/dev/voicexml/tags/audio-tag.md), [\<assign>](/dev/voicexml/tags/assign-tag.md), [\<clear>](/dev/voicexml/tags/clear-tag.md), [\<disconnect>](/dev/voicexml/tags/disconnect-tag.md), [\<data>](/dev/voicexml/tags/data-tag.md), [\<enumerate>](/dev/voicexml/tags/enumerate-tag.md), [\<exit>](/dev/voicexml/tags/exit-tag.md), [\<foreach>](/dev/voicexml/tags/foreach-tag.md), [\<goto>](/dev/voicexml/tags/goto-tag.md), [\<if>](/dev/voicexml/tags/if-tag.md), [\<log>](/dev/voicexml/tags/log-tag.md), [\<prompt>](/dev/voicexml/tags/prompt-tag.md), [\<reprompt>](/dev/voicexml/tags/reprompt-tag.md), [\<return>](/dev/voicexml/tags/return-tag.md), [\<script>](/dev/voicexml/tags/script-tag.md), [\<submit>](/dev/voicexml/tags/submit-tag.md), [\<throw>](/dev/voicexml/tags/throw-tag.md), [\<value>](/dev/voicexml/tags/value-tag.md), [\<var>](/dev/voicexml/tags/var-tag.md)

### Parent Tags

[\<field>](/dev/voicexml/tags/field-tag.md), [\<form>](/dev/voicexml/tags/form-tag.md), [\<initial>](/dev/voicexml/tags/initial-tag.md), [\<menu>](/dev/voicexml/tags/menu-tag.md), [\<record>](/dev/voicexml/tags/record-tag.md), [\<subdialog>](/dev/voicexml/tags/subdialog-tag.md), [\<transfer>](/dev/voicexml/tags/transfer-tag.md), [\<vxml>](/dev/voicexml/tags/vxml-tag.md)
