Exception: ACTV::Error

Inherits:
StandardError
  • Object
show all
Defined in:
lib/actv/error.rb,
lib/actv/error/forbidden.rb,
lib/actv/error/not_found.rb,
lib/actv/error/bad_gateway.rb,
lib/actv/error/bad_request.rb,
lib/actv/error/client_error.rb,
lib/actv/error/server_error.rb,
lib/actv/error/unauthorized.rb,
lib/actv/error/not_acceptable.rb,
lib/actv/error/enhance_your_calm.rb,
lib/actv/error/service_unavailable.rb,
lib/actv/error/internal_server_error.rb

Overview

Custom error class for rescuing from all Twitter errors

Direct Known Subclasses

ClientError, ServerError

Defined Under Namespace

Classes: BadGateway, BadRequest, ClientError, EnhanceYourCalm, Forbidden, InternalServerError, NotAcceptable, NotFound, ServerError, ServiceUnavailable, Unauthorized

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(exception = $!) ⇒ Twitter::Error

Initializes a new Error object

Parameters:

  • exception (Exception, String) (defaults to: $!)


18
19
20
21
22
23
24
25
# File 'lib/actv/error.rb', line 18

def initialize(exception=$!)
  if exception.respond_to?(:backtrace)
    super(exception.message)
    @wrapped_exception = exception
  else
    super(exception.to_s)
  end
end

Instance Attribute Details

#wrapped_exceptionObject (readonly)

Returns the value of attribute wrapped_exception.



4
5
6
# File 'lib/actv/error.rb', line 4

def wrapped_exception
  @wrapped_exception
end

Class Method Details

.descendantsObject



10
11
12
# File 'lib/actv/error.rb', line 10

def self.descendants
  ObjectSpace.each_object(::Class).select{|klass| klass < self}
end

.errorsObject



6
7
8
# File 'lib/actv/error.rb', line 6

def self.errors
  @errors ||= Hash[descendants.map{|klass| [klass.const_get(:HTTP_STATUS_CODE), klass]}]
end

Instance Method Details

#backtraceObject



27
28
29
# File 'lib/actv/error.rb', line 27

def backtrace
  @wrapped_exception ? @wrapped_exception.backtrace : super
end