Exception: Warrant::WarrantError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/warrant/errors.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code = nil, message = nil, http_status = nil, http_headers = nil, http_body = nil, json_body = nil) ⇒ WarrantError

Returns a new instance of WarrantError.



18
19
20
21
22
23
24
25
26
# File 'lib/warrant/errors.rb', line 18

def initialize(code = nil, message = nil, http_status = nil, http_headers = nil, http_body = nil, json_body = nil)
    @code = code
    @headers = headers
    @message = message
    @http_status = http_status
    @http_headers = http_headers
    @http_body = http_body
    @json_body = json_body
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



16
17
18
# File 'lib/warrant/errors.rb', line 16

def code
  @code
end

#headersObject (readonly)

Returns the value of attribute headers.



16
17
18
# File 'lib/warrant/errors.rb', line 16

def headers
  @headers
end

#http_bodyObject (readonly)

Returns the value of attribute http_body.



16
17
18
# File 'lib/warrant/errors.rb', line 16

def http_body
  @http_body
end

#http_headersObject (readonly)

Returns the value of attribute http_headers.



16
17
18
# File 'lib/warrant/errors.rb', line 16

def http_headers
  @http_headers
end

#http_statusObject (readonly)

Returns the value of attribute http_status.



16
17
18
# File 'lib/warrant/errors.rb', line 16

def http_status
  @http_status
end

#json_bodyObject (readonly)

Returns the value of attribute json_body.



16
17
18
# File 'lib/warrant/errors.rb', line 16

def json_body
  @json_body
end

#messageObject (readonly)

Returns the value of attribute message.



16
17
18
# File 'lib/warrant/errors.rb', line 16

def message
  @message
end

Class Method Details

.initialize_error_from_response(response) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/warrant/errors.rb', line 28

def self.initialize_error_from_response(response)
    response_json = JSON.parse(response.body)
    self.new(
        response_json['code'],
        Util.snake_case(response_json['message']),
        response.code,
        response.to_hash,
        response.body,
        response_json
    )
end