Sha256: 990d14c688224d7e73fc4ff50a1f8c2c2502c4aa08d28a77583b342a1da1fa40

Contents?: true

Size: 826 Bytes

Versions: 5

Compression:

Stored size: 826 Bytes

Contents

Error Handling
==============

Exceptions
----------
If the Twilio API returns a 400 or a 500 level HTTP response,
the twilio-ruby library will throw a :class:`Twilio::REST::RequestError`.
400-level errors are normal during API operation ("Invalid number",
"Cannot deliver SMS to that number", for example) and should be
handled appropriately.

.. code-block:: ruby

    require 'twilio-ruby'

    # To find these visit https://www.twilio.com/user/account
    account_sid = "ACXXXXXXXXXXXXXXXXX"
    auth_token = "YYYYYYYYYYYYYYYYYY"

    begin
        @client = Twilio::REST::Client.new account_sid, auth_token
        client.messages.create({
            from: '+1234567890',
            to: '+1234567890',
            body: 'Hello world'
        })
    rescue Twilio::REST::RequestError => e
        puts e.message
    end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
twilio-ruby-3.14.2 docs/usage/errors.rst
twilio-ruby-3.14.1 docs/usage/errors.rst
twilio-ruby-3.14.0 docs/usage/errors.rst
twilio-ruby-3.13.1 docs/usage/errors.rst
twilio-ruby-3.13.0 docs/usage/errors.rst