Exception: EmpireAvenue::Error

Inherits:
StandardError
  • Object
show all
Defined in:
lib/empireavenue/error.rb,
lib/empireavenue/error/forbidden.rb,
lib/empireavenue/error/not_found.rb,
lib/empireavenue/error/client_error.rb,
lib/empireavenue/error/decode_error.rb,
lib/empireavenue/error/server_error.rb,
lib/empireavenue/error/configuration_error.rb,
lib/empireavenue/error/service_unavailable.rb,
lib/empireavenue/error/internal_server_error.rb,
lib/empireavenue/error/identity_map_key_error.rb

Overview

customer error class for any errors

Direct Known Subclasses

ClientError, DecodeError, ServerError

Defined Under Namespace

Classes: ClientError, ConfigurationError, DecodeError, Forbidden, IdentityMapKeyError, InternalServerError, NotFound, ServerError, ServiceUnavailable

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(exception = $!, response_headers = {}) ⇒ EmpireAvenue::Error

Initializes a new Error object

Parameters:

  • exception (Exception, String) (defaults to: $!)
  • response_headers (Hash) (defaults to: {})


21
22
23
24
25
# File 'lib/empireavenue/error.rb', line 21

def initialize(exception=$!, response_headers={})
  #@rate_limit = EmpireAvenue::RateLimit.new(response_headers)
  @wrapped_exception = exception
  exception.respond_to?(:backtrace) ? super(exception.message) : super(exception.to_s)
end

Instance Attribute Details

#wrapped_exceptionObject (readonly)

Returns the value of attribute wrapped_exception.



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

def wrapped_exception
  @wrapped_exception
end

Class Method Details

.descendantsArray

Returns:

  • (Array)


12
13
14
# File 'lib/empireavenue/error.rb', line 12

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

.errorsHash

Returns:

  • (Hash)


7
8
9
# File 'lib/empireavenue/error.rb', line 7

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/empireavenue/error.rb', line 27

def backtrace
  @wrapped_exception.respond_to?(:backtrace) ? @wrapped_exception.backtrace : super
end