Class: Bobot::ErrorParser

Inherits:
Object
  • Object
show all
Defined in:
lib/bobot/error_parser.rb

Overview

Parses and raises Facebook response errors for the send API.

Constant Summary collapse

INTERNAL_ERROR_CODES =
{
  1200 => [],
}.freeze
ACCESS_TOKEN_ERROR_CODES =
{
  190 => [],
}.freeze
ACCOUNT_LINKING_ERROR_CODES =
{
  10_303 => [],
}.freeze
LIMIT_ERROR_CODES =
{
  4 => [2_018_022],
  100 => [2_018_109],
  613 => [nil],
}.freeze
BAD_PARAMETER_ERROR_CODES =
{
  100 => [nil, 2_018_001],
}.freeze
PERMISSION_ERROR_CODES =
{
  10 => [2_018_065, 2_018_108],
  200 => [1_545_041, 2_018_028, 2_018_027, 2_018_021],
  230 => [nil],
}.freeze

Class Method Summary collapse

Class Method Details

.raise_errors_from(response, extras = {}) ⇒ Object

Raise any errors in the given response.

response - A HTTParty::Response object.

Returns nil if no errors were found, otherwises raises appropriately

Raises:



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/bobot/error_parser.rb', line 38

def raise_errors_from(response, extras = {})
  return false if response.nil? || !response.key?('error')

  error = response['error']

  error_code = error['code']
  error_subcode = error['error_subcode']

  error['extras'] = extras

  raise_code_only_error(error_code, error) if error_subcode.nil?

  raise_code_subcode_error(error_code, error_subcode, error)

  # Default to unidentified error
  raise FacebookError.new(error)
end