lib/outreach/errors.rb in outreach-0.0.1 vs lib/outreach/errors.rb in outreach-0.0.2
- old
+ new
@@ -2,14 +2,19 @@
module Outreach
module Errors
class Unauthorized < StandardError; end
- def check_for_error(status_code)
+ def check_for_error(status_code, response_body)
# raise error if status code isn't 200
case status_code.to_i
when 401
- raise Unauthorized.new("Authorization failed")
+ description = begin
+ JSON.parse(response_body).fetch("error_description")
+ rescue
+ "Unauthorized"
+ end
+ raise Unauthorized.new(description)
end
end
end
end
\ No newline at end of file