Exception: Kitchen::Driver::Azure::OperationError
- Inherits:
-
StandardError
- Object
- StandardError
- Kitchen::Driver::Azure::OperationError
- Defined in:
- lib/kitchen/driver/azure/errors.rb
Overview
Raised when Azure Resource Manager returns an error response.
Replaces MsRestAzure2::AzureOperationError, keeping the body
accessor the driver's rescue blocks already rely on.
Note the explicit ::StandardError: Test Kitchen defines
Kitchen::StandardError, and this class lives inside module Kitchen,
so a bare StandardError here would resolve to that instead.
Instance Attribute Summary collapse
-
#body ⇒ Hash
readonly
The parsed error body, as returned by ARM.
-
#status ⇒ Integer
readonly
The HTTP status code of the failing response.
Instance Method Summary collapse
-
#code ⇒ String?
The Azure error code, when ARM supplied one.
-
#detail ⇒ String?
Azure's own explanation, when ARM supplied one.
-
#initialize(message, status: nil, body: {}) ⇒ OperationError
constructor
A new instance of OperationError.
Constructor Details
#initialize(message, status: nil, body: {}) ⇒ OperationError
Returns a new instance of OperationError.
31 32 33 34 35 |
# File 'lib/kitchen/driver/azure/errors.rb', line 31 def initialize(, status: nil, body: {}) super() @status = status @body = body end |
Instance Attribute Details
#body ⇒ Hash (readonly)
The parsed error body, as returned by ARM.
21 22 23 |
# File 'lib/kitchen/driver/azure/errors.rb', line 21 def body @body end |
#status ⇒ Integer (readonly)
The HTTP status code of the failing response.
26 27 28 |
# File 'lib/kitchen/driver/azure/errors.rb', line 26 def status @status end |
Instance Method Details
#code ⇒ String?
The Azure error code, when ARM supplied one.
40 41 42 |
# File 'lib/kitchen/driver/azure/errors.rb', line 40 def code body.is_a?(Hash) ? body.dig("error", "code") : nil end |
#detail ⇒ String?
Azure's own explanation, when ARM supplied one.
message is this class's summary of the request that failed; this
is what Azure said about it, which is usually the part worth showing
somebody.
51 52 53 |
# File 'lib/kitchen/driver/azure/errors.rb', line 51 def detail body.is_a?(Hash) ? body.dig("error", "message") : nil end |