Exception: QuickPay::API::Error
- Inherits:
-
StandardError
- Object
- StandardError
- QuickPay::API::Error
- Defined in:
- lib/quickpay/api/error.rb
Direct Known Subclasses
BadGateway, BadRequest, Conflict, Forbidden, GatewayTimeout, InternalServerError, MethodNotAllowed, NotAcceptable, NotFound, PaymentRequired, ServiceUnavailable, TooManyRequest, Unauthorized
Defined Under Namespace
Classes: BadGateway, BadRequest, Conflict, Forbidden, GatewayTimeout, InternalServerError, MethodNotAllowed, NotAcceptable, NotFound, PaymentRequired, ServiceUnavailable, TooManyRequest, Unauthorized
Constant Summary collapse
- CLASS_MAP =
{ 400 => "BadRequest", 401 => "Unauthorized", 402 => "PaymentRequired", 403 => "Forbidden", 404 => "NotFound", 405 => "MethodNotAllowed", 406 => "NotAcceptable", 409 => "Conflict", 429 => "TooManyRequest", 500 => "InternalServerError", 502 => "BadGateway", 503 => "ServiceUnavailable", 504 => "GatewayTimeout" }.freeze
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(status, body, headers) ⇒ Error
constructor
A new instance of Error.
- #to_s ⇒ Object (also: #inspect)
Constructor Details
#initialize(status, body, headers) ⇒ Error
Returns a new instance of Error.
36 37 38 39 40 |
# File 'lib/quickpay/api/error.rb', line 36 def initialize(status, body, headers) @status = status @body = body @headers = headers end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
34 35 36 |
# File 'lib/quickpay/api/error.rb', line 34 def body @body end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
34 35 36 |
# File 'lib/quickpay/api/error.rb', line 34 def headers @headers end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
34 35 36 |
# File 'lib/quickpay/api/error.rb', line 34 def status @status end |
Class Method Details
.by_status_code(status, body, headers) ⇒ Object
47 48 49 50 51 52 |
# File 'lib/quickpay/api/error.rb', line 47 def self.by_status_code(status, body, headers) raise QuickPay::API::Error.new(status, body, headers) unless CLASS_MAP[status] klass = QuickPay::API::Error.const_get(CLASS_MAP[status]) raise klass.new(status, body, headers) end |
Instance Method Details
#to_s ⇒ Object Also known as: inspect
42 43 44 |
# File 'lib/quickpay/api/error.rb', line 42 def to_s "#<#{self.class}: status=#{status}, body=#{body.inspect}, headers=#{headers.inspect}>" end |