Exception: Cryptomus::Errors::ApiError

Inherits:
Error
  • Object
show all
Defined in:
lib/cryptomus/errors.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response, msg = nil) ⇒ ApiError

Returns a new instance of ApiError.

Parameters:

  • response (Faraday::Response, nil)
  • msg (String, nil) (defaults to: nil)


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