Exception: Twitter::RESTError

Inherits:
RuntimeError
  • Object
show all
Includes:
ClassUtilMixin
Defined in:
lib/vendor/twitter/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 <tt>Twitter::Client</tt>.
  # 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]

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ClassUtilMixin

included

Instance Attribute Details

#codeObject

Returns the value of attribute code.



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

def code
  @code
end

#messageObject

Returns the value of attribute message.



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

def message
  @message
end

#uriObject

Returns the value of attribute uri.



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

def uri
  @uri
end

Instance Method Details

#to_sObject

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/vendor/twitter/lib/twitter/core.rb', line 111

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