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.



440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
# File 'lib/adwords4r.rb', line 440

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.



413
414
415
# File 'lib/adwords4r.rb', line 413

def code
  @code
end

#code_exObject

Returns the value of attribute code_ex.



431
432
433
# File 'lib/adwords4r.rb', line 431

def code_ex
  @code_ex
end

#detailObject

Returns the value of attribute detail.



414
415
416
# File 'lib/adwords4r.rb', line 414

def detail
  @detail
end

#fieldObject

Returns the value of attribute field.



415
416
417
# File 'lib/adwords4r.rb', line 415

def field
  @field
end

#indexObject

Returns the value of attribute index.



416
417
418
# File 'lib/adwords4r.rb', line 416

def index
  @index
end

#inner_faultObject

Returns the value of attribute inner_fault.



433
434
435
# File 'lib/adwords4r.rb', line 433

def inner_fault
  @inner_fault
end

#internalObject

Returns the value of attribute internal.



411
412
413
# File 'lib/adwords4r.rb', line 411

def internal
  @internal
end

#isExemptableObject

Returns the value of attribute isExemptable.



417
418
419
# File 'lib/adwords4r.rb', line 417

def isExemptable
  @isExemptable
end

#messageObject

Returns the value of attribute message.



412
413
414
# File 'lib/adwords4r.rb', line 412

def message
  @message
end

#soap_faultcodeObject

Returns the value of attribute soap_faultcode.



408
409
410
# File 'lib/adwords4r.rb', line 408

def soap_faultcode
  @soap_faultcode
end

#soap_faultcode_exObject

Returns the value of attribute soap_faultcode_ex.



429
430
431
# File 'lib/adwords4r.rb', line 429

def soap_faultcode_ex
  @soap_faultcode_ex
end

#soap_faultstringObject

Returns the value of attribute soap_faultstring.



409
410
411
# File 'lib/adwords4r.rb', line 409

def soap_faultstring
  @soap_faultstring
end

#soap_faultstring_exObject

Returns the value of attribute soap_faultstring_ex.



430
431
432
# File 'lib/adwords4r.rb', line 430

def soap_faultstring_ex
  @soap_faultstring_ex
end

#textIndexObject

Returns the value of attribute textIndex.



418
419
420
# File 'lib/adwords4r.rb', line 418

def textIndex
  @textIndex
end

#textLengthObject

Returns the value of attribute textLength.



419
420
421
# File 'lib/adwords4r.rb', line 419

def textLength
  @textLength
end

#top_codeObject

Returns the value of attribute top_code.



410
411
412
# File 'lib/adwords4r.rb', line 410

def top_code
  @top_code
end

#triggerObject

Returns the value of attribute trigger.



420
421
422
# File 'lib/adwords4r.rb', line 420

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!



428
429
430
# File 'lib/adwords4r.rb', line 428

def trigger_ex
  @trigger_ex
end