Exception: DianPing::Error
- Inherits:
-
StandardError
- Object
- StandardError
- DianPing::Error
- Defined in:
- lib/dianping/error.rb,
lib/dianping/error/not_found.rb,
lib/dianping/error/client_error.rb
Overview
Custom error class for rescuing from all DianPing errors
Direct Known Subclasses
Defined Under Namespace
Classes: ClientError, NotFound
Class Method Summary collapse
Instance Method Summary collapse
- #backtrace ⇒ Object
-
#initialize(exception = $!, response_headers = {}) ⇒ DianPing::Error
constructor
Initializes a new Error object.
Constructor Details
#initialize(exception = $!, response_headers = {}) ⇒ DianPing::Error
Initializes a new Error object
20 21 22 |
# File 'lib/dianping/error.rb', line 20 def initialize(exception=$!, response_headers={}) exception.respond_to?(:backtrace) ? super(exception.) : super(exception.to_s) end |
Class Method Details
.descendants ⇒ Array
11 12 13 |
# File 'lib/dianping/error.rb', line 11 def self.descendants ObjectSpace.each_object(::Class).select{|klass| klass < self} end |
.errors ⇒ Hash
6 7 8 |
# File 'lib/dianping/error.rb', line 6 def self.errors @errors ||= Hash[descendants.map{|klass| [klass.const_get(:HTTP_STATUS_CODE)]}] end |
Instance Method Details
#backtrace ⇒ Object
24 25 26 |
# File 'lib/dianping/error.rb', line 24 def backtrace @wrapped_exception.respond_to?(:backtrace) ? @wrapped_exception.backtrace : super end |