Exception: XTwitterScraper::Errors::APIStatusError
- Defined in:
- lib/x_twitter_scraper/errors.rb,
sig/x_twitter_scraper/errors.rbs
Direct Known Subclasses
AuthenticationError, BadRequestError, ConflictError, InternalServerError, NotFoundError, PermissionDeniedError, RateLimitError, UnprocessableEntityError
Instance Attribute Summary collapse
Attributes inherited from APIError
Attributes inherited from Error
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(url:, status:, headers:, body:, request:, response:, message: nil) ⇒ APIStatusError
constructor
private
A new instance of APIStatusError.
Constructor Details
#initialize(url:, status:, headers:, body:, request:, response:, message: nil) ⇒ APIStatusError
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of APIStatusError.
186 187 188 189 190 191 192 193 194 195 196 197 |
# File 'lib/x_twitter_scraper/errors.rb', line 186 def initialize(url:, status:, headers:, body:, request:, response:, message: nil) ||= {url: url.to_s, status: status, body: body} super( url: url, status: status, headers: headers, body: body, request: request, response: response, message: &.to_s ) end |
Instance Attribute Details
#status ⇒ Integer
|
|
# File 'lib/x_twitter_scraper/errors.rb', line 173
|
Class Method Details
.for(url:, status:, headers:, body:, request:, response:, message: nil) ⇒ self
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
# File 'lib/x_twitter_scraper/errors.rb', line 139 def self.for(url:, status:, headers:, body:, request:, response:, message: nil) kwargs = { url: url, status: status, headers: headers, body: body, request: request, response: response, message: } case status in 400 XTwitterScraper::Errors::BadRequestError.new(**kwargs) in 401 XTwitterScraper::Errors::AuthenticationError.new(**kwargs) in 403 XTwitterScraper::Errors::PermissionDeniedError.new(**kwargs) in 404 XTwitterScraper::Errors::NotFoundError.new(**kwargs) in 409 XTwitterScraper::Errors::ConflictError.new(**kwargs) in 422 XTwitterScraper::Errors::UnprocessableEntityError.new(**kwargs) in 429 XTwitterScraper::Errors::RateLimitError.new(**kwargs) in (500..) XTwitterScraper::Errors::InternalServerError.new(**kwargs) else XTwitterScraper::Errors::APIStatusError.new(**kwargs) end end |