sferik / twitter-ruby

A Ruby interface to the Twitter API.
http://www.rubydoc.info/gems/twitter
MIT License
4.58k stars 1.31k forks source link

NameError: uninitialized constant Twitter::Error::RequestEntityTooLarge #902

Closed Jetinho closed 1 year ago

Jetinho commented 6 years ago

Hello,

I faced this problem while rescuing Twitter Errors :

NameError: uninitialized constant Twitter::Error::RequestEntityTooLarge Error happened in production, and the same error occurs when I enter Twitter::Error::RequestEntityTooLarge in console.

From what I saw the constant is defined as well as other errors in twitter/lib/twitter/error.rb

Anyone faced the same issue ?

I was rescuing errors that way : (I got the errors list from the documentation).

    rescue Twitter::Error::BadRequest => e
      raise BadRequestError.new(e)
    rescue Twitter::Error::Unauthorized => e
      raise AuthenticationError.new(e)
    rescue Twitter::Error::Forbidden, Twitter::Error::NotFound, Twitter::Error::NotAcceptable,
      Twitter::Error::RequestEntityTooLarge, Twitter::Error::UnprocessableEntity, Twitter::Error::TooManyRequests,
      Twitter::Error::InternalServerError, Twitter::Error::BadGateway, Twitter::Error::ServiceUnavailable,
      Twitter::Error::GatewayTimeout, Twitter::Error::DuplicateStatus, Twitter::Error::AlreadyFavorited,
      Twitter::Error::AlreadyRetweeted, Twitter::Error::AlreadyRetweeted => e
      raise PublicationError.new(e)
    end

Now I'll rather rescue this way to avoid the issue :

    rescue Twitter::Error::BadRequest => e
      raise BadRequestError.new(e)
    rescue Twitter::Error::Unauthorized => e
      raise AuthenticationError.new(e)
    rescue Twitter::Error::ClientError, Twitter::Error::ServerError => e
      raise PublicationError.new(e)
    end