Exception: Twitter::RESTError

Inherits:
RuntimeError
  • Object
show all
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

Constant Summary collapse

@@REGISTRY =
{}
@@ATTRIBUTES =
[:code, :message, :uri, :error]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ClassUtilMixin

included

Instance Attribute Details

#codeObject

Returns the value of attribute code.



117
118
119
# File 'lib/twitter/core.rb', line 117

def code
  @code
end

#errorObject

Returns the value of attribute error.



117
118
119
# File 'lib/twitter/core.rb', line 117

def error
  @error
end

#messageObject

Returns the value of attribute message.



117
118
119
# File 'lib/twitter/core.rb', line 117

def message
  @message
end

#uriObject

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

.registryObject



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

def registry
  @@REGISTRY
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 >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