Class: MsRestAzure::AzureOperationError

Inherits:
MsRest::HttpOperationError
  • Object
show all
Defined in:
lib/ms_rest_azure/azure_operation_error.rb

Overview

Class which represents an Azure error.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ AzureOperationError

Creates and initialize new instance of the AzureOperationError class.

Parameters:

  • the (Hash)

    HTTP request data (uri, body, headers).

  • the (Faraday::Response)

    HTTP response object.

  • body (String)

    the HTTP response body.

  • error (String)

    message.



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/ms_rest_azure/azure_operation_error.rb', line 24

def initialize(*args)
  super(*args)

  # Try to parse @body to find useful error message and code
  # Body should meet the error condition response requirements for Microsoft REST API Guidelines
  # https://github.com/Microsoft/api-guidelines/blob/master/Guidelines.md#7102-error-condition-responses
  begin
    unless @body.nil?
      @error_message = @body['error']['message']
      @error_code = @body['error']['code']
      @msg = "#{@msg}: #{@error_code}: #{@error_message}"
    end
  rescue
  end
end

Instance Attribute Details

#error_codeString

Returns the error code.

Returns:

  • (String)

    the error code.



15
16
17
# File 'lib/ms_rest_azure/azure_operation_error.rb', line 15

def error_code
  @error_code
end

#error_messageString

Returns the error message.

Returns:

  • (String)

    the error message.



12
13
14
# File 'lib/ms_rest_azure/azure_operation_error.rb', line 12

def error_message
  @error_message
end