Exception: VistarClient::APIError

Inherits:
Error
  • Object
show all
Defined in:
lib/vistar_client/error.rb

Overview

Raised when the API returns an error response (HTTP 4xx/5xx).

This error includes the HTTP status code and response body for debugging.

Examples:

Handle API errors

begin
  client.request_ad(params)
rescue VistarClient::APIError => e
  puts "API error: #{e.message}"
  puts "Status code: #{e.status_code}"
  puts "Response body: #{e.response_body}"
end

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, status_code: nil, response_body: nil) ⇒ APIError

Initialize an APIError with optional HTTP details.



58
59
60
61
62
# File 'lib/vistar_client/error.rb', line 58

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

Instance Attribute Details

#response_bodyHash, ... (readonly)



50
51
52
# File 'lib/vistar_client/error.rb', line 50

def response_body
  @response_body
end

#status_codeInteger? (readonly)



47
48
49
# File 'lib/vistar_client/error.rb', line 47

def status_code
  @status_code
end