Sha256: b7dd8d2dde573139f66ed7be0d7b2ec6859964920e18bceafc7780684d94441b

Contents?: true

Size: 806 Bytes

Versions: 37

Compression:

Stored size: 806 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

37 entries across 37 versions & 1 rubygems

Version Path
twilio-ruby-4.13.0 docs/usage/errors.rst
twilio-ruby-4.12.1 docs/usage/errors.rst
twilio-ruby-4.11.1 docs/usage/errors.rst
twilio-ruby-4.11.0 docs/usage/errors.rst
twilio-ruby-4.10.0.edge docs/usage/errors.rst
twilio-ruby-4.10.0 docs/usage/errors.rst
twilio-ruby-4.9.1 docs/usage/errors.rst
twilio-ruby-4.9.1.edge docs/usage/errors.rst
twilio-ruby-4.9.0 docs/usage/errors.rst
twilio-ruby-4.9.0.edge docs/usage/errors.rst
twilio-ruby-4.8.0 docs/usage/errors.rst
twilio-ruby-4.7.0 docs/usage/errors.rst
twilio-ruby-4.8.3.edge docs/usage/errors.rst
twilio-ruby-4.8.2.edge docs/usage/errors.rst
twilio-ruby-4.8.1.edge docs/usage/errors.rst
twilio-ruby-4.8.0.edge docs/usage/errors.rst
twilio-ruby-4.6.2 docs/usage/errors.rst
twilio-ruby-4.6.1 docs/usage/errors.rst
twilio-ruby-4.6.0 docs/usage/errors.rst
twilio-ruby-4.7.0.edge docs/usage/errors.rst