### Home Classes Methods

### In Files

- lib/twitter/error.rb

### Parent

StandardError

### Namespace

- MODULE Twitter::Error::Code
- CLASS Twitter::Error::AlreadyFavorited
- CLASS Twitter::Error::AlreadyRetweeted
- CLASS Twitter::Error::BadGateway
- CLASS Twitter::Error::BadRequest
- CLASS Twitter::Error::ClientError
- CLASS Twitter::Error::ConfigurationError
- CLASS Twitter::Error::DuplicateStatus
- CLASS Twitter::Error::Forbidden
- CLASS Twitter::Error::GatewayTimeout
- CLASS Twitter::Error::InternalServerError
- CLASS Twitter::Error::NotAcceptable
- CLASS Twitter::Error::NotFound
- CLASS Twitter::Error::RequestTimeout
- CLASS Twitter::Error::ServerError
- CLASS Twitter::Error::ServiceUnavailable
- CLASS Twitter::Error::TooManyRequests
- CLASS Twitter::Error::UnacceptableIO
- CLASS Twitter::Error::Unauthorized
- CLASS Twitter::Error::UnprocessableEntity

### Methods

- ::errors
- ::forbidden_messages
- ::from_response
- ::new

### Class/Module Index

Quicksearch

- Twitter
- Twitter::Arguments
- Twitter::Base
- Twitter::BasicUser
- Twitter::Client
- Twitter::Configuration
- Twitter::Creatable
- Twitter::Cursor
- Twitter::DirectMessage
- Twitter::Entities
- Twitter::Entity
- Twitter::Entity::Hashtag
- Twitter::Entity::Symbol
- Twitter::Entity::URI
- Twitter::Entity::URL
- Twitter::Entity::UserMention
- Twitter::Enumerable
- Twitter::Error
- Twitter::Error::AlreadyFavorited
- Twitter::Error::AlreadyRetweeted
- Twitter::Error::BadGateway
- Twitter::Error::BadRequest
- Twitter::Error::ClientError
- Twitter::Error::Code
- Twitter::Error::ConfigurationError
- Twitter::Error::DuplicateStatus
- Twitter::Error::Forbidden
- Twitter::Error::GatewayTimeout
- Twitter::Error::InternalServerError
- Twitter::Error::NotAcceptable
- Twitter::Error::NotFound
- Twitter::Error::RequestTimeout
- Twitter::Error::ServerError
- Twitter::Error::ServiceUnavailable
- Twitter::Error::TooManyRequests
- Twitter::Error::UnacceptableIO
- Twitter::Error::Unauthorized
- Twitter::Error::UnprocessableEntity
- Twitter::Factory
- Twitter::Geo
- Twitter::Geo::Point
- Twitter::Geo::Polygon
- Twitter::GeoFactory
- Twitter::GeoResults
- Twitter::Identity
- Twitter::Language
- Twitter::List
- Twitter::Media
- Twitter::Media::Photo
- Twitter::MediaFactory
- Twitter::Metadata
- Twitter::OEmbed
- Twitter::Place
- Twitter::Profile
- Twitter::ProfileBanner
- Twitter::REST
- Twitter::REST::API
- Twitter::REST::Client
- Twitter::REST::DirectMessages
- Twitter::REST::Favorites
- Twitter::REST::FriendsAndFollowers
- Twitter::REST::Help
- Twitter::REST::Lists
- Twitter::REST::OAuth
- Twitter::REST::PlacesAndGeo
- Twitter::REST::Request
- Twitter::REST::Request::MultipartWithFile
- Twitter::REST::Response
- Twitter::REST::Response::ParseErrorJson
- Twitter::REST::Response::ParseJson
- Twitter::REST::Response::RaiseError
- Twitter::REST::SavedSearches
- Twitter::REST::Search
- Twitter::REST::SpamReporting
- Twitter::REST::SuggestedUsers
- Twitter::REST::Timelines
- Twitter::REST::Trends
- Twitter::REST::Tweets
- Twitter::REST::Undocumented
- Twitter::REST::Users
- Twitter::REST::Utils
- Twitter::RateLimit
- Twitter::Relationship
- Twitter::Request
- Twitter::SavedSearch
- Twitter::SearchResults
- Twitter::Settings
- Twitter::Size
- Twitter::SourceUser
- Twitter::Streaming
- Twitter::Streaming::Client
- Twitter::Streaming::Connection
- Twitter::Streaming::DeletedTweet
- Twitter::Streaming::Event
- Twitter::Streaming::FriendList
- Twitter::Streaming::MessageParser
- Twitter::Streaming::Response
- Twitter::Streaming::StallWarning
- Twitter::Suggestion
- Twitter::TargetUser
- Twitter::Token
- Twitter::Trend
- Twitter::TrendResults
- Twitter::Tweet
- Twitter::User
- Twitter::Utils
- Twitter::Utils::ClassMethods
- Twitter::Version

No matching classes.

# Twitter::Error

Custom error class for rescuing from all Twitter errors

### Constants

AlreadyPosted
Codes
EnhanceYourCalm
RateLimited

### Attributes

code[R]
rate_limit[R]

### Public Class Methods

errors() click to toggle source

@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,
        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

forbidden_messages() click to toggle source

    # File lib/twitter/error.rb, line 61
    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

from_response(response) click to toggle source

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

new(message = '', rate_limit = {}, code = nil) click to toggle source

Initializes a new Error object

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

    # File lib/twitter/error.rb, line 97
    def initialize(message = '', rate_limit = {}, code = nil)
      super(message)
      @rate_limit = Twitter::RateLimit.new(rate_limit)
      @code = code
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.