Exception: Pike13::APIError

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

Overview

Base class for all API-related errors Provides access to HTTP status and response body

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message = nil, http_status: nil, response_body: nil) ⇒ APIError

Returns a new instance of APIError.

Parameters:

  • message (String, nil) (defaults to: nil)

    Error message

  • http_status (Integer, nil) (defaults to: nil)

    HTTP status code

  • response_body (Hash, String, nil) (defaults to: nil)

    API response body



24
25
26
27
28
# File 'lib/pike13/errors.rb', line 24

def initialize(message = nil, http_status: nil, response_body: nil)
  @http_status = http_status
  @response_body = response_body
  super(message)
end

Instance Attribute Details

#http_statusInteger? (readonly)

HTTP status code from the API

Returns:

  • (Integer, nil)

    the current value of http_status



18
19
20
# File 'lib/pike13/errors.rb', line 18

def http_status
  @http_status
end

#response_bodyHash, ... (readonly)

Response body from the API

Returns:

  • (Hash, String, nil)

    the current value of response_body



18
19
20
# File 'lib/pike13/errors.rb', line 18

def response_body
  @response_body
end