catch and rethrow errors

Questions and answers about IVR programming for Plum DEV

Moderators: admin, support

  • Author
  • Message
Offline

graham

  • Posts: 1
  • Joined: Fri Oct 19, 2018 3:48 pm

catch and rethrow errors

PostMon Oct 22, 2018 9:58 am

I want to have a generic catch method capture all events:

<?xml version="1.0"?>
<vxml version="2.0">
<form>
<block>
<throw event="blah" message="hello, world!"/>
</block>
</form>
<catch>
<prompt>
I'm sorry. We caught an error.
// do transfer
</prompt>
</catch>
</vxml>

I then want to do a transfer to a number we have, then re-raise the error so it appears in the logs. Can I do this?

Is there a list of all events that can be raised? If I have to do this manually to re-raise I probably need a full list.
Offline

support

  • Posts: 3628
  • Joined: Mon Jun 02, 2003 3:47 pm
  • Location: Boston, MA

Re: catch and rethrow errors

PostMon Oct 22, 2018 2:00 pm

Hi Graham,

Errors are logged automatically in the call logs whenever a <catch> element is triggered. In the code below, <submit> will trigger the <catch> element as the file process_id.php does not exist. The error (error.badfetch) will be logged before user is transferred.

Furthermore, the <catch> element can be used for all generic events without having to specify a distinct type of events. As shown in the code below, <catch> element will be called to receive the <throw event="blah">. At the same time, it will also be called after any errors, including badfetch, no-input or no-match errors after id_num input.

Code: Select all
<?xml version="1.0"?>
<vxml version="2.0">
  <form>
    <block>
      <throw event="blah" message="Hello, world"/>
    </block>
   
    <field name="id_num" type="digits?length=5">
      <prompt>
        Please enter your id number.
      </prompt>
      <filled>
        <prompt>
          Thank you.
        </prompt>
        <submit next="process_id.php" namelist="id_num"/>
      </filled>
    </field>
   
    <catch>
      <prompt>
   <value expr="_message"/>
      </prompt>
      <goto next="#transfer"/>
    </catch>
  </form>
 
  <form id="transfer">
    <transfer dest="16177123000">
      <prompt>
   Transferring.
      </prompt>
    </transfer>
  </form>
</vxml>


Regards,
Plum Support

Return to Plum DEV Q&A

Who is online

Users browsing this forum: Google [Bot] and 1 guest

cron