Parent

Class/Module Index [+]

Quicksearch

Twitter::Error

Custom error class for rescuing from all Twitter errors

Attributes

cause[R]
code[R]
rate_limit[R]
wrapped_exception[R]

Public Class Methods

errors() click to toggle source

@return [Hash]

# File lib/twitter/error.rb, line 44
def errors
  @errors ||= descendants.reduce({}) do |hash, klass|
    hash[klass::HTTP_STATUS_CODE] = klass
    hash
  end
end
from_response(response = {}) click to toggle source

Create a new error from an HTTP response

@param response [Hash] @return [Twitter::Error]

# File lib/twitter/error.rb, line 38
def from_response(response = {})
  error, code = parse_error(response[:body])
  new(error, response[:response_headers], code)
end
new(exception = $ERROR_INFO, response_headers = {}, code = nil) click to toggle source

Initializes a new Error object

@param exception [Exception, String] @param response_headers [Hash] @param code [Integer] @return [Twitter::Error]

# File lib/twitter/error.rb, line 79
def initialize(exception = $ERROR_INFO, response_headers = {}, code = nil)
  @rate_limit = RateLimit.new(response_headers)
  @cause = exception
  @code = code
  exception.respond_to?(:message) ? super(exception.message) : super(exception.to_s)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.