Exception: Walinko::ApiError

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

Overview

Base class for every error response returned by the API. Carries the full diagnostic payload — HTTP status, server-side ‘error_code`, the `X-Request-Id` (handy for support tickets), and the optional `details` blob.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, http_status:, error_code: nil, request_id: nil, details: nil, body: nil) ⇒ ApiError

Returns a new instance of ApiError.



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

def initialize(message, http_status:, error_code: nil, request_id: nil,
               details: nil, body: nil)
  super(message)
  @http_status = http_status
  @error_code  = error_code
  @request_id  = request_id
  @details     = details || {}
  @body        = body
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



26
27
28
# File 'lib/walinko/errors.rb', line 26

def body
  @body
end

#detailsObject (readonly)

Returns the value of attribute details.



26
27
28
# File 'lib/walinko/errors.rb', line 26

def details
  @details
end

#error_codeObject (readonly)

Returns the value of attribute error_code.



26
27
28
# File 'lib/walinko/errors.rb', line 26

def error_code
  @error_code
end

#http_statusObject (readonly)

Returns the value of attribute http_status.



26
27
28
# File 'lib/walinko/errors.rb', line 26

def http_status
  @http_status
end

#request_idObject (readonly)

Returns the value of attribute request_id.



26
27
28
# File 'lib/walinko/errors.rb', line 26

def request_id
  @request_id
end

Instance Method Details

#inspectObject



38
39
40
41
42
43
# File 'lib/walinko/errors.rb', line 38

def inspect
  parts = [self.class.name, "status=#{http_status}"]
  parts << "code=#{error_code}" if error_code
  parts << "request_id=#{request_id}" if request_id
  "#<#{parts.join(' ')} message=#{message.inspect}>"
end