Handling Service Errors
Any time the Twilio Service encounters a problem, it will send an XML document back to the client detailing the problem, as well as providing a link to more information on how to solve it. When this happens, TwilioClient will throw a TwilioClientException,
which inherits from System.Exception. TwilioClientException has two additional properties that will be helpful in troubleshooting the API call:
- RestException - the response from Twilio in the form of a TwilioRestException object
- PostedObject - an XmlDocument with the serialized data that was sent to Twilio.
The TwilioClientException can be handled through standard .NET error handling techniques, and processed accordingly.
// do something
catch (TwilioClientException ex)
// do something about Twilio
catch (Exception e)
// something else has happened
Twilio Response Formats