Method: FbGraph::Exception.handle_structured_response

Defined in:
lib/fb_graph/exception.rb

.handle_structured_response(status, details, headers) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/fb_graph/exception.rb', line 7

def handle_structured_response(status, details, headers)
  if (error = details[:error])
    klass = klass_for_header(headers, error) || klass_for_structured_body(error)
    message = [error[:type], error[:message]].join(' :: ')
    if klass
      raise klass.new(message, details)
    else
      handle_response status, message, details
    end
  else
    message = [details[:error_code], details[:error_msg]].compact.join(' :: ')
    handle_response status, message, details
  end
end