Exception: Cryptomus::Errors::ApiError
- Defined in:
- lib/cryptomus/errors.rb
Instance Attribute Summary collapse
- #response([Faraday: :Response,nil]) ⇒ Object readonly
-
#response_body([Hash,nil]) ⇒ Object
readonly
Returns the value of attribute response_body.
- #status([Integer,nil]) ⇒ Object readonly
Instance Method Summary collapse
-
#initialize(response, msg = nil) ⇒ ApiError
constructor
A new instance of ApiError.
Constructor Details
#initialize(response, msg = nil) ⇒ ApiError
Returns a new instance of ApiError.
16 17 18 19 20 21 22 23 |
# File 'lib/cryptomus/errors.rb', line 16 def initialize(response, msg = nil) @response = response @status = response&.status @response_body = response&.body body_msg = response_body.is_a?(Hash) ? JSON.generate(response_body) : response_body msg ||= "Response #{status}, #{body_msg}" if response super(msg || self.class.name) end |
Instance Attribute Details
#response([Faraday: :Response,nil]) ⇒ Object (readonly)
12 13 14 |
# File 'lib/cryptomus/errors.rb', line 12 def response @response end |
#response_body([Hash,nil]) ⇒ Object (readonly)
Returns the value of attribute response_body.
12 |
# File 'lib/cryptomus/errors.rb', line 12 attr_reader :response, :status, :response_body |
#status([Integer,nil]) ⇒ Object (readonly)
12 |
# File 'lib/cryptomus/errors.rb', line 12 attr_reader :response, :status, :response_body |