Sha256: d806f6e79804b0db5cadf26e4f2cee2a2de0feec2015ded188ce17fef58854f9

Contents?: true

Size: 692 Bytes

Versions: 10

Compression:

Stored size: 692 Bytes

Contents

module TwitterAuth
  module Dispatcher
    module Shared
      def handle_response(response)
        case response
        when Net::HTTPOK 
          begin
            JSON.parse(response.body)
          rescue JSON::ParserError
            response.body
          end
        else
          message = begin
            JSON.parse(response.body)['error']
          rescue JSON::ParserError
            if match = response.body.match(/<error>(.*)<\/error>/)
              match[1]
            else
              'An error occurred processing your Twitter request.'
            end
          end

          raise TwitterAuth::Dispatcher::Error, message
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
mbleigh-twitter-auth-0.1.10 lib/twitter_auth/dispatcher/shared.rb
mbleigh-twitter-auth-0.1.11 lib/twitter_auth/dispatcher/shared.rb
mbleigh-twitter-auth-0.1.5 lib/twitter_auth/dispatcher/shared.rb
mbleigh-twitter-auth-0.1.8 lib/twitter_auth/dispatcher/shared.rb
twitter-auth-0.1.10 lib/twitter_auth/dispatcher/shared.rb
twitter-auth-0.1.11 lib/twitter_auth/dispatcher/shared.rb
twitter-auth-0.1.5 lib/twitter_auth/dispatcher/shared.rb
twitter-auth-0.1.8 lib/twitter_auth/dispatcher/shared.rb
twitter-auth-0.1.7 lib/twitter_auth/dispatcher/shared.rb
twitter-auth-0.1.9 lib/twitter_auth/dispatcher/shared.rb