Exception: Twitter::RESTError

Inherits:
RuntimeError
  • Object
show all
Includes:
ClassUtilMixin
Defined in:
lib/twitter/core.rb

Overview

Exception subclass 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

Constant Summary collapse

@@ATTRIBUTES =
[:code, :message, :uri, :error]

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ClassUtilMixin

included

Instance Attribute Details

#code ⇒ Object

Returns the value of attribute code.



105
106
107
# File 'lib/twitter/core.rb', line 105

def code
  @code
end

#error ⇒ Object

Returns the value of attribute error.



105
106
107
# File 'lib/twitter/core.rb', line 105

def error
  @error
end

#message ⇒ Object

Returns the value of attribute message.



105
106
107
# File 'lib/twitter/core.rb', line 105

def message
  @message
end

#uri ⇒ Object

Returns the value of attribute uri.



105
106
107
# File 'lib/twitter/core.rb', line 105

def uri
  @uri
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"



111
112
113
# File 'lib/twitter/core.rb', line 111

def to_s
  "HTTP #{@code}: #{@message} at #{@uri}"
end