Exception: Koala::Facebook::APIError
- Inherits:
-
KoalaError
- Object
- StandardError
- KoalaError
- Koala::Facebook::APIError
- Defined in:
- lib/koala/errors.rb
Overview
Facebook responded with an error to an API request. If the exception contains a nil http_status, then the error was detected before making a call to Facebook. (e.g. missing access token)
Direct Known Subclasses
BadFacebookResponse, ClientError, OAuthTokenRequestError, ServerError
Instance Attribute Summary collapse
-
#fb_ada_usage ⇒ Object
Returns the value of attribute fb_ada_usage.
-
#fb_app_usage ⇒ Object
Returns the value of attribute fb_app_usage.
-
#fb_buc_usage ⇒ Object
Returns the value of attribute fb_buc_usage.
-
#fb_error_code ⇒ Object
Returns the value of attribute fb_error_code.
-
#fb_error_debug ⇒ Object
Returns the value of attribute fb_error_debug.
-
#fb_error_debug_trace_id ⇒ Object
Returns the value of attribute fb_error_debug_trace_id.
-
#fb_error_message ⇒ Object
Returns the value of attribute fb_error_message.
-
#fb_error_rev ⇒ Object
Returns the value of attribute fb_error_rev.
-
#fb_error_subcode ⇒ Object
Returns the value of attribute fb_error_subcode.
-
#fb_error_trace_id ⇒ Object
Returns the value of attribute fb_error_trace_id.
-
#fb_error_type ⇒ Object
Returns the value of attribute fb_error_type.
-
#fb_error_user_msg ⇒ Object
Returns the value of attribute fb_error_user_msg.
-
#fb_error_user_title ⇒ Object
Returns the value of attribute fb_error_user_title.
-
#http_status ⇒ Object
Returns the value of attribute http_status.
-
#response_body ⇒ Object
Returns the value of attribute response_body.
Instance Method Summary collapse
-
#initialize(http_status, response_body, error_info = nil) ⇒ Object
constructor
Create a new API Error.
Constructor Details
#initialize(http_status, response_body, error_info = nil) ⇒ Object
Create a new API Error
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/koala/errors.rb', line 44 def initialize(http_status, response_body, error_info = nil) if response_body self.response_body = response_body.strip else self.response_body = '' end self.http_status = http_status if error_info && error_info.is_a?(String) = error_info else unless error_info begin error_info = JSON.parse(response_body)['error'] if response_body rescue end error_info ||= {} end self.fb_error_type = error_info["type"] self.fb_error_code = error_info["code"] self.fb_error_subcode = error_info["error_subcode"] self. = error_info["message"] self.fb_error_user_msg = error_info["error_user_msg"] self.fb_error_user_title = error_info["error_user_title"] self.fb_error_trace_id = error_info["fbtrace_id"] self.fb_error_debug_trace_id = error_info["x-fb-trace-id"] self.fb_error_debug = error_info["x-fb-debug"] self.fb_error_rev = error_info["x-fb-rev"] self.fb_buc_usage = json_parse_for(error_info, "x-business-use-case-usage") self.fb_ada_usage = json_parse_for(error_info, "x-ad-account-usage") self.fb_app_usage = json_parse_for(error_info, "x-app-usage") error_array = [] %w(type code error_subcode message error_user_title error_user_msg fbtrace_id x-fb-trace-id x-fb-debug x-fb-rev).each do |key| error_array << "#{key}: #{error_info[key]}" if error_info[key] end if error_array.empty? = self.response_body else = error_array.join(', ') end end += " [HTTP #{http_status}]" if http_status super() end |
Instance Attribute Details
#fb_ada_usage ⇒ Object
Returns the value of attribute fb_ada_usage.
16 17 18 |
# File 'lib/koala/errors.rb', line 16 def fb_ada_usage @fb_ada_usage end |
#fb_app_usage ⇒ Object
Returns the value of attribute fb_app_usage.
16 17 18 |
# File 'lib/koala/errors.rb', line 16 def fb_app_usage @fb_app_usage end |
#fb_buc_usage ⇒ Object
Returns the value of attribute fb_buc_usage.
16 17 18 |
# File 'lib/koala/errors.rb', line 16 def fb_buc_usage @fb_buc_usage end |
#fb_error_code ⇒ Object
Returns the value of attribute fb_error_code.
16 17 18 |
# File 'lib/koala/errors.rb', line 16 def fb_error_code @fb_error_code end |
#fb_error_debug ⇒ Object
Returns the value of attribute fb_error_debug.
16 17 18 |
# File 'lib/koala/errors.rb', line 16 def fb_error_debug @fb_error_debug end |
#fb_error_debug_trace_id ⇒ Object
Returns the value of attribute fb_error_debug_trace_id.
16 17 18 |
# File 'lib/koala/errors.rb', line 16 def fb_error_debug_trace_id @fb_error_debug_trace_id end |
#fb_error_message ⇒ Object
Returns the value of attribute fb_error_message.
16 17 18 |
# File 'lib/koala/errors.rb', line 16 def @fb_error_message end |
#fb_error_rev ⇒ Object
Returns the value of attribute fb_error_rev.
16 17 18 |
# File 'lib/koala/errors.rb', line 16 def fb_error_rev @fb_error_rev end |
#fb_error_subcode ⇒ Object
Returns the value of attribute fb_error_subcode.
16 17 18 |
# File 'lib/koala/errors.rb', line 16 def fb_error_subcode @fb_error_subcode end |
#fb_error_trace_id ⇒ Object
Returns the value of attribute fb_error_trace_id.
16 17 18 |
# File 'lib/koala/errors.rb', line 16 def fb_error_trace_id @fb_error_trace_id end |
#fb_error_type ⇒ Object
Returns the value of attribute fb_error_type.
16 17 18 |
# File 'lib/koala/errors.rb', line 16 def fb_error_type @fb_error_type end |
#fb_error_user_msg ⇒ Object
Returns the value of attribute fb_error_user_msg.
16 17 18 |
# File 'lib/koala/errors.rb', line 16 def fb_error_user_msg @fb_error_user_msg end |
#fb_error_user_title ⇒ Object
Returns the value of attribute fb_error_user_title.
16 17 18 |
# File 'lib/koala/errors.rb', line 16 def fb_error_user_title @fb_error_user_title end |
#http_status ⇒ Object
Returns the value of attribute http_status.
16 17 18 |
# File 'lib/koala/errors.rb', line 16 def http_status @http_status end |
#response_body ⇒ Object
Returns the value of attribute response_body.
16 17 18 |
# File 'lib/koala/errors.rb', line 16 def response_body @response_body end |