Exception: Echowrap::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Echowrap::Error
- Defined in:
- lib/echowrap/error.rb,
lib/echowrap/error/forbidden.rb,
lib/echowrap/error/not_found.rb,
lib/echowrap/error/bad_gateway.rb,
lib/echowrap/error/bad_request.rb,
lib/echowrap/error/client_error.rb,
lib/echowrap/error/server_error.rb,
lib/echowrap/error/unauthorized.rb,
lib/echowrap/error/not_acceptable.rb,
lib/echowrap/error/gateway_timeout.rb,
lib/echowrap/error/too_many_requests.rb,
lib/echowrap/error/configuration_error.rb,
lib/echowrap/error/service_unavailable.rb,
lib/echowrap/error/unprocessable_entity.rb,
lib/echowrap/error/internal_server_error.rb
Overview
Custom error class for rescuing from all Echowrap errors
Direct Known Subclasses
Defined Under Namespace
Classes: BadGateway, BadRequest, ClientError, ConfigurationError, Forbidden, GatewayTimeout, InternalServerError, NotAcceptable, NotFound, ServerError, ServiceUnavailable, TooManyRequests, Unauthorized, UnprocessableEntity
Constant Summary collapse
- EnhanceYourCalm =
TooManyRequests
- RateLimited =
TooManyRequests
Instance Attribute Summary collapse
-
#rate_limit ⇒ Object
readonly
Returns the value of attribute rate_limit.
-
#wrapped_exception ⇒ Object
readonly
Returns the value of attribute wrapped_exception.
Class Method Summary collapse
Instance Method Summary collapse
- #backtrace ⇒ Object
-
#initialize(exception = $!, response_headers = {}) ⇒ Echowrap::Error
constructor
Initializes a new Error object.
Constructor Details
#initialize(exception = $!, response_headers = {}) ⇒ Echowrap::Error
Initializes a new Error object
21 22 23 24 25 |
# File 'lib/echowrap/error.rb', line 21 def initialize(exception=$!, response_headers={}) @rate_limit = Echowrap::RateLimit.new(response_headers) @wrapped_exception = exception exception.respond_to?(:backtrace) ? super(exception.) : super(exception.to_s) end |
Instance Attribute Details
#rate_limit ⇒ Object (readonly)
Returns the value of attribute rate_limit.
4 5 6 |
# File 'lib/echowrap/error.rb', line 4 def rate_limit @rate_limit end |
#wrapped_exception ⇒ Object (readonly)
Returns the value of attribute wrapped_exception.
4 5 6 |
# File 'lib/echowrap/error.rb', line 4 def wrapped_exception @wrapped_exception end |
Class Method Details
.descendants ⇒ Array
12 13 14 |
# File 'lib/echowrap/error.rb', line 12 def self.descendants ObjectSpace.each_object(::Class).select{|klass| klass < self} end |
.errors ⇒ Hash
7 8 9 |
# File 'lib/echowrap/error.rb', line 7 def self.errors @errors ||= Hash[descendants.map{|klass| [klass.const_get(:HTTP_STATUS_CODE), klass]}] end |
Instance Method Details
#backtrace ⇒ Object
27 28 29 |
# File 'lib/echowrap/error.rb', line 27 def backtrace @wrapped_exception.respond_to?(:backtrace) ? @wrapped_exception.backtrace : super end |