Module: Outreach::Errors

Included in:
Request
Defined in:
lib/outreach/errors.rb

Defined Under Namespace

Classes: Unauthorized

Instance Method Summary collapse

Instance Method Details

#check_for_error(status_code, response_body) ⇒ Object



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

def check_for_error(status_code, response_body)
  response_hash = JSON.parse(response_body)
  if response_hash['errors'].present? &&
      response_hash['errors']['status'].present?
    status_code = response_hash['errors']['status']
  end

  # raise error if status code isn't 200
  case status_code.to_i
  when 401
    unauthorized_error(response_body)
  end
end