Exception: Twitter::RESTError
- Inherits:
-
RuntimeError
- Object
- RuntimeError
- Twitter::RESTError
- Includes:
- ClassUtilMixin
- Defined in:
- lib/twitter/core.rb
Overview
Exception API base class raised when there is an error encountered upon querying or posting to the remote Twitter REST API.
To consume and query any RESTError raised by Twitter4R: begin
Do something with your instance of Twitter::Client.
Maybe something like:
timeline = twitter.timeline_for(:public)
rescue RESTError => re puts re.code, re.message, re.uri end Which on the code raising a RESTError will output something like: 404 Resource Not Found /i_am_crap.json
Direct Known Subclasses
BadGatewayError, ForbiddenError, InternalServerError, NotAcceptableError, NotFoundError, NotModifiedError, RateLimitError, SearchRateLimitError, ServiceUnavailableError, UnauthorizedError
Constant Summary collapse
- @@REGISTRY =
{}
- @@ATTRIBUTES =
[:code, :message, :uri, :error]
Instance Attribute Summary collapse
-
#code ⇒ Object
Returns the value of attribute code.
-
#error ⇒ Object
Returns the value of attribute error.
-
#message ⇒ Object
Returns the value of attribute message.
-
#uri ⇒ Object
Returns the value of attribute uri.
Class Method Summary collapse
Instance Method Summary collapse
-
#to_s ⇒ Object
Returns string in following format: "HTTP #@code: #@message at #@uri" For example, "HTTP 404: Resource Not Found at /i_am_crap.json >This is the error message sent back by the Twitter.com API".
Methods included from ClassUtilMixin
Instance Attribute Details
#code ⇒ Object
Returns the value of attribute code.
117 118 119 |
# File 'lib/twitter/core.rb', line 117 def code @code end |
#error ⇒ Object
Returns the value of attribute error.
117 118 119 |
# File 'lib/twitter/core.rb', line 117 def error @error end |
#message ⇒ Object
Returns the value of attribute message.
117 118 119 |
# File 'lib/twitter/core.rb', line 117 def @message end |
#uri ⇒ Object
Returns the value of attribute uri.
117 118 119 |
# File 'lib/twitter/core.rb', line 117 def uri @uri end |
Class Method Details
.register(status_code) ⇒ Object
110 111 112 |
# File 'lib/twitter/core.rb', line 110 def register(status_code) @@REGISTRY[status_code] = self end |
.registry ⇒ Object
106 107 108 |
# File 'lib/twitter/core.rb', line 106 def registry @@REGISTRY end |
Instance Method Details
#to_s ⇒ Object
Returns string in following format: "HTTP #@code: #@message at #@uri" For example, "HTTP 404: Resource Not Found at /i_am_crap.json >This is the error message sent back by the Twitter.com API"
124 125 126 |
# File 'lib/twitter/core.rb', line 124 def to_s "HTTP #{@code}: #{@message} at #{@uri}" end |