Exception: BudaApi::Errors::ApiError

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

Overview

Base error class for all API errors

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, status_code: nil, response_body: nil, response_headers: nil) ⇒ ApiError

Returns a new instance of ApiError.



10
11
12
13
14
15
# File 'lib/buda_api/errors.rb', line 10

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

Instance Attribute Details

#response_bodyObject (readonly)

Returns the value of attribute response_body.



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

def response_body
  @response_body
end

#response_headersObject (readonly)

Returns the value of attribute response_headers.



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

def response_headers
  @response_headers
end

#status_codeObject (readonly)

Returns the value of attribute status_code.



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

def status_code
  @status_code
end

Instance Method Details

#to_sObject



17
18
19
20
21
# File 'lib/buda_api/errors.rb', line 17

def to_s
  msg = super
  msg += " (HTTP #{@status_code})" if @status_code
  msg
end