class AdManagerApi::Errors::ApiException
This class encapsulates base class for API exceptions. More specific exceptions are generated based on Service WSDL.
Attributes
array_fields[R]
Public Class Methods
new(exception_fault, registry)
click to toggle source
Calls superclass method
# File lib/ad_manager_api/errors.rb, line 30 def initialize(exception_fault, registry) @array_fields ||= [] extractor = AdsCommon::ResultsExtractor.new(registry) exception_type = exception_fault[:application_exception_type] exception_data = (exception_type.nil?) ? exception_fault : extractor.extract_exception_data(exception_fault, exception_type) exception_data.each { |key, value| set_field(key, value) } super(exception_data[:message]) end
Private Instance Methods
arrayize(object)
click to toggle source
Makes sure object is an array
# File lib/ad_manager_api/errors.rb, line 51 def arrayize(object) return [] if object.nil? return object.is_a?(Array) ? object : [object] end
is_array_field(field)
click to toggle source
Should a field be forced to be an array
# File lib/ad_manager_api/errors.rb, line 57 def is_array_field(field) return @array_fields.include?(field.to_s) end
set_field(field, value)
click to toggle source
Sets instance's property to a value if it is defined
# File lib/ad_manager_api/errors.rb, line 43 def set_field(field, value) if respond_to?(field) value = arrayize(value) if is_array_field(field) instance_variable_set("@#{field}", value) end end