Exception: Kitchen::Driver::ProxmoxErrors::ApiError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/kitchen/driver/proxmox/errors.rb

Overview

Structured error raised by ApiClient on non-2xx responses.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status_code, response_body) ⇒ ApiError

Returns a new instance of ApiError.



10
11
12
13
14
# File 'lib/kitchen/driver/proxmox/errors.rb', line 10

def initialize(status_code, response_body)
  @status_code = status_code.to_i
  @response_body = response_body
  super("Proxmox API error #{status_code}: #{response_body}")
end

Instance Attribute Details

#response_bodyObject (readonly)

Returns the value of attribute response_body.



8
9
10
# File 'lib/kitchen/driver/proxmox/errors.rb', line 8

def response_body
  @response_body
end

#status_codeObject (readonly)

Returns the value of attribute status_code.



8
9
10
# File 'lib/kitchen/driver/proxmox/errors.rb', line 8

def status_code
  @status_code
end

Instance Method Details

#vmid_conflict?Boolean

Returns true when the error indicates a VMID is already in use.

Returns:

  • (Boolean)


17
18
19
20
21
22
# File 'lib/kitchen/driver/proxmox/errors.rb', line 17

def vmid_conflict?
  return false unless status_code == 400 || status_code == 500

  response_body.match?(/already exists/i) ||
    response_body.match?(/unable to create VM \d+/i)
end