Exception: AdWords::Error::ApiError

Inherits:
Error
  • Object
show all
Defined in:
lib/adwords4r.rb

Overview

Raised if a call returns with a SOAP error, gives you easy access to adwords error fields

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(soap_fault) ⇒ ApiError

Constructor for ApiError.

Args:

  • soap_fault: SOAP fault returned by the service.



405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
# File 'lib/adwords4r.rb', line 405

def initialize(soap_fault)
  @soap_faultcode = protect { soap_fault.faultcode }
  @soap_faultcode_ex = protect { soap_fault.faultcode.text }
  @soap_faultstring = protect { soap_fault.faultstring }
  @soap_faultstring_ex = protect { soap_fault.faultstring.text }
  @inner_fault = protect { soap_fault }
  if protect { soap_fault.detail and soap_fault.detail.fault }
    fault = soap_fault.detail.fault
    @top_code = protect { fault.code }
    @internal = protect { fault.internal }
    @message = protect { fault.message }
    @trigger_ex = protect { fault.trigger }
    @code_ex = protect { fault.code }
    if protect { fault.errors and fault.errors.size > 0 }
      error = fault.errors.first
      @code = protect { error.code }
      @detail = protect { error.detail }
      @field = protect { error.field }
      @index = protect { error.index }
      @isExemptable = protect { error.isExemptable }
      @textIndex = protect { error.textIndex }
      @textLength = protect { error.textLength }
      @trigger = protect { error.trigger }
    end
  end
end

Instance Attribute Details

#codeObject

Returns the value of attribute code.



378
379
380
# File 'lib/adwords4r.rb', line 378

def code
  @code
end

#code_exObject

Returns the value of attribute code_ex.



396
397
398
# File 'lib/adwords4r.rb', line 396

def code_ex
  @code_ex
end

#detailObject

Returns the value of attribute detail.



379
380
381
# File 'lib/adwords4r.rb', line 379

def detail
  @detail
end

#fieldObject

Returns the value of attribute field.



380
381
382
# File 'lib/adwords4r.rb', line 380

def field
  @field
end

#indexObject

Returns the value of attribute index.



381
382
383
# File 'lib/adwords4r.rb', line 381

def index
  @index
end

#inner_faultObject

Returns the value of attribute inner_fault.



398
399
400
# File 'lib/adwords4r.rb', line 398

def inner_fault
  @inner_fault
end

#internalObject

Returns the value of attribute internal.



376
377
378
# File 'lib/adwords4r.rb', line 376

def internal
  @internal
end

#isExemptableObject

Returns the value of attribute isExemptable.



382
383
384
# File 'lib/adwords4r.rb', line 382

def isExemptable
  @isExemptable
end

#messageObject

Returns the value of attribute message.



377
378
379
# File 'lib/adwords4r.rb', line 377

def message
  @message
end

#soap_faultcodeObject

Returns the value of attribute soap_faultcode.



373
374
375
# File 'lib/adwords4r.rb', line 373

def soap_faultcode
  @soap_faultcode
end

#soap_faultcode_exObject

Returns the value of attribute soap_faultcode_ex.



394
395
396
# File 'lib/adwords4r.rb', line 394

def soap_faultcode_ex
  @soap_faultcode_ex
end

#soap_faultstringObject

Returns the value of attribute soap_faultstring.



374
375
376
# File 'lib/adwords4r.rb', line 374

def soap_faultstring
  @soap_faultstring
end

#soap_faultstring_exObject

Returns the value of attribute soap_faultstring_ex.



395
396
397
# File 'lib/adwords4r.rb', line 395

def soap_faultstring_ex
  @soap_faultstring_ex
end

#textIndexObject

Returns the value of attribute textIndex.



383
384
385
# File 'lib/adwords4r.rb', line 383

def textIndex
  @textIndex
end

#textLengthObject

Returns the value of attribute textLength.



384
385
386
# File 'lib/adwords4r.rb', line 384

def textLength
  @textLength
end

#top_codeObject

Returns the value of attribute top_code.



375
376
377
# File 'lib/adwords4r.rb', line 375

def top_code
  @top_code
end

#triggerObject

Returns the value of attribute trigger.



385
386
387
# File 'lib/adwords4r.rb', line 385

def trigger
  @trigger
end

#trigger_exObject

The *_ex attributes have been added to correct deficiencies with the initial implementation. They should expose more useful information (i.e. text of errors instead of a SOAP element) and proper mapping of a fault’s trigger and code. The old attributes are left behind for backward compatibility; hopefully this isn’t too confusing!



393
394
395
# File 'lib/adwords4r.rb', line 393

def trigger_ex
  @trigger_ex
end