Exception: CheckoutRu::Error
- Inherits:
-
RuntimeError
- Object
- RuntimeError
- CheckoutRu::Error
- Defined in:
- lib/checkout_ru/error.rb
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(message, code = nil) ⇒ Error
constructor
A new instance of Error.
Constructor Details
#initialize(message, code = nil) ⇒ Error
Returns a new instance of Error.
27 28 29 30 |
# File 'lib/checkout_ru/error.rb', line 27 def initialize(, code = nil) @code = code super() end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
25 26 27 |
# File 'lib/checkout_ru/error.rb', line 25 def code @code end |
Class Method Details
.construct(response) ⇒ Object
4 5 6 7 8 9 10 11 12 13 |
# File 'lib/checkout_ru/error.rb', line 4 def construct(response) code, = parse_error_response(response) = "#{} (checkout.ru error, code #{code})" case code when 4 then NoDeliveryFoundError.new(, code) when nil then new(response.inspect) else new(, code) end end |
.parse_error_response(response) ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/checkout_ru/error.rb', line 15 def parse_error_response(response) if response.respond_to?(:[]) && response[:error_code] && response[:error_message] [response[:error_code], response[:error_message]] end end |