Class: AdwordsApi::Errors::ApiException

Inherits:
AdsCommon::Errors::ApiException
  • Object
show all
Defined in:
lib/adwords_api/errors.rb

Overview

This class encapsulates a v13 or v20xx exception. Errors are stored in an array, with each error being a hash, rather than a Ruby object. This is for the purpose of making the errors independent from the SOAP toolkit being used.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message = nil, errors = nil, code = nil, trigger = nil) ⇒ ApiException

Returns a new instance of ApiException.



34
35
36
# File 'lib/adwords_api/errors.rb', line 34

def initialize(message = nil, errors = nil, code = nil, trigger = nil)
  @message, @errors, @code, @trigger = message, errors, code, trigger
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



32
33
34
# File 'lib/adwords_api/errors.rb', line 32

def code
  @code
end

#errorsObject (readonly)

Returns the value of attribute errors.



32
33
34
# File 'lib/adwords_api/errors.rb', line 32

def errors
  @errors
end

#triggerObject (readonly)

Returns the value of attribute trigger.



32
33
34
# File 'lib/adwords_api/errors.rb', line 32

def trigger
  @trigger
end

Instance Method Details

#operation_index_for_error(error) ⇒ Object

Returns the source operation index for an error

Args:

  • error: the error to be analyzed

Returns:

  • index for the source operation, nil if none



46
47
48
49
50
51
52
53
54
55
# File 'lib/adwords_api/errors.rb', line 46

def operation_index_for_error(error)
  if error and error.include? :field_path and error[:field_path]
    parts = error[:field_path].split('.')
    if parts.length > 0
      match = parts.first.match(/operations\[(\d)\]/)
      return match ? match[1].to_i : nil
    end
  end
  return nil
end