Class: AdwordsApi::Errors::ApiException
- Inherits:
-
AdsCommon::Errors::ApiException
- Object
- AdsCommon::Errors::ApiException
- AdwordsApi::Errors::ApiException
- 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
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#trigger ⇒ Object
readonly
Returns the value of attribute trigger.
Instance Method Summary collapse
-
#initialize(message = nil, errors = nil, code = nil, trigger = nil) ⇒ ApiException
constructor
A new instance of ApiException.
-
#operation_index_for_error(error) ⇒ Object
Returns the source operation index for an error.
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( = nil, errors = nil, code = nil, trigger = nil) @message, @errors, @code, @trigger = , errors, code, trigger end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
32 33 34 |
# File 'lib/adwords_api/errors.rb', line 32 def code @code end |
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
32 33 34 |
# File 'lib/adwords_api/errors.rb', line 32 def errors @errors end |
#trigger ⇒ Object (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 |