class AdManagerApi::Errors::ApiException
This class encapsulates base class for API exceptions. More specific exceptions are generated based on Service WSDL.
Attributes
Public Class Methods
Source
# 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
Calls superclass method
Private Instance Methods
Source
# File lib/ad_manager_api/errors.rb, line 51 def arrayize(object) return [] if object.nil? return object.is_a?(Array) ? object : [object] end
Makes sure object is an array
Source
# File lib/ad_manager_api/errors.rb, line 57 def is_array_field(field) return @array_fields.include?(field.to_s) end
Should a field be forced to be an array
Source
# 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
Sets instance’s property to a value if it is defined