StandardError
Custom error class for rescuing from all Twitter errors
@return [Hash]
# File lib/twitter/error.rb, line 44 def errors @errors ||= { 400 => Twitter::Error::BadRequest, 401 => Twitter::Error::Unauthorized, 403 => Twitter::Error::Forbidden, 404 => Twitter::Error::NotFound, 406 => Twitter::Error::NotAcceptable, 408 => Twitter::Error::RequestTimeout, 420 => Twitter::Error::EnhanceYourCalm, 422 => Twitter::Error::UnprocessableEntity, 429 => Twitter::Error::TooManyRequests, 500 => Twitter::Error::InternalServerError, 502 => Twitter::Error::BadGateway, 503 => Twitter::Error::ServiceUnavailable, 504 => Twitter::Error::GatewayTimeout, } end
# File lib/twitter/error.rb, line 62 def forbidden_messages @forbidden_messages ||= { 'Status is a duplicate.' => Twitter::Error::DuplicateStatus, 'You have already favorited this status.' => Twitter::Error::AlreadyFavorited, 'sharing is not permissible for this status (Share validations failed)' => Twitter::Error::AlreadyRetweeted, } end
Create a new error from an HTTP response
@param response [Faraday::Response] @return [Twitter::Error]
# File lib/twitter/error.rb, line 38 def from_response(response) message, code = parse_error(response.body) new(message, response.response_headers, code) end
Initializes a new Error object
@param message [Exception, String] @param rate_limit [Hash] @param code [Integer] @return [Twitter::Error]
# File lib/twitter/error.rb, line 98 def initialize(message = '', rate_limit = {}, code = nil) super(message) @rate_limit = Twitter::RateLimit.new(rate_limit) @code = code end
Generated with the Darkfish Rdoc Generator 2.