Exception: FacebookAds::APIError

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

Direct Known Subclasses

ClientError, ServerError

Constant Summary collapse

ERROR_ATTRS =
[
  :headers, :fb_message, :type, :code,
  :error_subcode, :is_transient, :error_user_title,
  :error_user_msg, :error_data, :fbtrace_id,
]

Instance Method Summary collapse

Constructor Details

#initialize(api_response) ⇒ APIError

Returns a new instance of APIError.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/facebook_ads/errors.rb', line 22

def initialize(api_response)
  send("headers=", api_response.headers)
  error_obj = api_response.result
  @api_response = api_response

  if error_obj.is_a?(Hash)
    error_obj = error_obj['error'] if error_obj.has_key?('error')
    error_obj.each do |k,v|
      k = "fb_#{k}" if k == 'message'
      send("#{k}=", v) if ERROR_ATTRS.include?(k.to_sym)
    end

    super("#{self.fb_message}: #{self.error_user_title} (fbtrace_id: #{self.fbtrace_id})")
  else
    super(error_obj)
  end
end

Instance Method Details

#getHeadersObject



40
41
42
# File 'lib/facebook_ads/errors.rb', line 40

def getHeaders
  self.headers
end