Class: Koala::Facebook::GraphErrorChecker

Inherits:
Object
  • Object
show all
Defined in:
lib/koala/api/graph_error_checker.rb

Overview

This class, given a Koala::HTTPService::Response object, will check for Graph API-specific errors. This returns an error of the appropriate type which can be immediately raised (non-batch) or added to the list of batch results (batch)

Constant Summary collapse

AUTHENTICATION_ERROR_CODES =

Facebook has a set of standardized error codes, some of which represent problems with the token.

[102, 190, 450, 452, 2500]
DEBUG_HEADERS =

Facebook can return debug information in the response headers – see developers.facebook.com/docs/graph-api/using-graph-api#bugdebug

["x-fb-debug", "x-fb-rev", "x-fb-trace-id"]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(http_status, body, headers) ⇒ GraphErrorChecker

Returns a new instance of GraphErrorChecker.



8
9
10
11
12
# File 'lib/koala/api/graph_error_checker.rb', line 8

def initialize(http_status, body, headers)
  @http_status = http_status.to_i
  @body = body
  @headers = headers
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



7
8
9
# File 'lib/koala/api/graph_error_checker.rb', line 7

def body
  @body
end

#headersObject (readonly)

Returns the value of attribute headers.



7
8
9
# File 'lib/koala/api/graph_error_checker.rb', line 7

def headers
  @headers
end

#http_statusObject (readonly)

Returns the value of attribute http_status.



7
8
9
# File 'lib/koala/api/graph_error_checker.rb', line 7

def http_status
  @http_status
end

Instance Method Details

#error_if_appropriateObject



22
23
24
25
26
# File 'lib/koala/api/graph_error_checker.rb', line 22

def error_if_appropriate
  if http_status >= 400
    error_class.new(http_status, body, error_info)
  end
end