Many developers have asked us how to catch unexpected errors in their code and/or errors in fetching a VoiceXML document from their web server. It’s possible to capture certain error events and act on those events in a dynamic fashion. For instance, if a web server that presents code to the Plum platform is unavailable, it’s possible to play a message to the caller, redirect the call to another number, or evoke a script that lives locally on the Plum platform via the scratchpad.
The <catch> tag can be used to handle these errors gracefully by intercepting specific events that can trigger alternative call flows.
Here’s some sample code that details an event handler.
<?xml version=”1.0″?>
<vxml version=”2.0″>
<form>
<block>
<!– “myevent” is thrown. Jump to the nearest “catch” for –>
<!– the “myevent” event. –>
<throw event=”myevent” message=”hello, world!”/>
</block>
<!– The “myevent” event will be caught here. –>
<catch event=”myevent”>
<prompt>
Caught my event with the following message:
<break time=”1s”/>
<value expr=”_message”/>
</prompt>
</catch>
</form>
</vxml>
The output of the above script would be:
Computer: Caught my event with the following message:
Computer: hello, world!
For more information, please sign up for a developer account or visit Plum’s VoiceXML tutorial.
