Page 1 of 1

catch and rethrow errors

Posted: Mon Oct 22, 2018 9:58 am
by graham
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.

Re: catch and rethrow errors

Posted: Mon Oct 22, 2018 2:00 pm
by support
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