Exception: Ecertic::Error

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

Overview

Error is the base error from which all other more specific Ecertic errors derive.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message = nil, http_status: nil, http_headers: nil, http_body: nil, response: nil) ⇒ Error

Returns a new instance of Error.



12
13
14
15
16
17
18
# File 'lib/ecertic/errors.rb', line 12

def initialize(message = nil, http_status: nil, http_headers: nil, http_body: nil, response: nil)
  @message = message
  @http_status = http_status || response&.status
  @http_headers = http_headers || response&.headers
  @http_body = http_body || response&.body
  @response = response
end

Instance Attribute Details

#http_bodyObject (readonly)

Returns the value of attribute http_body.



9
10
11
# File 'lib/ecertic/errors.rb', line 9

def http_body
  @http_body
end

#http_headersObject (readonly)

Returns the value of attribute http_headers.



8
9
10
# File 'lib/ecertic/errors.rb', line 8

def http_headers
  @http_headers
end

#http_statusObject (readonly)

Returns the value of attribute http_status.



7
8
9
# File 'lib/ecertic/errors.rb', line 7

def http_status
  @http_status
end

#messageObject (readonly)

Returns the value of attribute message.



6
7
8
# File 'lib/ecertic/errors.rb', line 6

def message
  @message
end

#responseObject (readonly)

Returns the value of attribute response.



10
11
12
# File 'lib/ecertic/errors.rb', line 10

def response
  @response
end

Instance Method Details

#to_sObject



20
21
22
23
# File 'lib/ecertic/errors.rb', line 20

def to_s
  status_string = @http_status.nil? ? "" : "(Status #{@http_status}) "
  "#{status_string}#{@message}"
end