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.
<!– “myevent” is thrown. Jump to the nearest “catch” for –>
<!– the “myevent” event. –>
<throw event=”myevent” message=”hello, world!”/>
<!– The “myevent” event will be caught here. –>
Caught my event with the following message:
The output of the above script would be:
Computer: Caught my event with the following message:
Computer: hello, world!