Exception: Kitchen::Driver::ProxmoxErrors::ApiError
- Inherits:
-
StandardError
- Object
- StandardError
- Kitchen::Driver::ProxmoxErrors::ApiError
- Defined in:
- lib/kitchen/driver/proxmox/errors.rb
Overview
Structured error raised by ApiClient on non-2xx responses.
Instance Attribute Summary collapse
-
#response_body ⇒ Object
readonly
Returns the value of attribute response_body.
-
#status_code ⇒ Object
readonly
Returns the value of attribute status_code.
Instance Method Summary collapse
-
#initialize(status_code, response_body) ⇒ ApiError
constructor
A new instance of ApiError.
-
#vmid_conflict? ⇒ Boolean
Returns true when the error indicates a VMID is already in use.
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_body ⇒ Object (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_code ⇒ Object (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.
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 |