# <throw>

Description

Throws a pre-defined event or application-specific event.

Syntax

    <throw
        event="event"
        eventexpr="ECMAScript_Expression"
        message="string"
        messageexpr="ECMAScript_Expression"/>

Attributes

Attribute | Description
event | The name of the event to be thrown. Exactly one of event or eventexpr must be specified.
eventexpr | An ECMAScript expression to be evaluated and used as the name of the event to be thrown. Exactly one of event or eventexpr must be specified.
message | A message string providing additional context about the event being thrown. For the pre-defined events thrown by the platform, the value of the message is platform-dependent. The message will be available as a variable within the scope of the `<catch>` element. Optional. (Only one of message or messageexpr can be specified.)
messageexpr | An ECMAScript expression to be evaluated and used as a message string, as documented under `message`, above. Optional. (Only one of message or messageexpr can be specified.)

Attribute Notes

- An `error.badfetch` event is thrown if more or less than one of `event` and `eventexpr` are specified, or if more than one of `message` and `messageexpr` are specified.

Parents

<block>, <catch>, <error>, <filled>, <foreach>, <help>, <if>, <noinput>, <nomatch>

Children

None.

Extensions

None.

Limitations/Restrictions

- `<throw>` cannot be used as a child of `<foreach>` when `<foreach>` is a child of `<prompt>`.
- If manually throwing the `connection.disconnect.hangup`/`telephone.disconnect.hangup` event, note that it can only be caught once during the execution of an application; see details.

Example

    <?xml version="1.0"?>
    <vxml version="2.0" xmlns="http://www.w3.org/2001/vxml">
      <catch event="goodbye">
        Thank you for calling. Goodbye.
        <exit/>
      </catch>
      <form>
        <field name="field1" type="boolean">
          <dtmf> * </dtmf>
          <prompt>Please press the star.</prompt>
          <filled>
            <if cond="field1 == '*'">
              <throw event="goodbye"/>
            </if>
          </filled>
        </field>
      </form>
    </vxml>