Skip to content
Browse files

fixing error handling

  • Loading branch information...
1 parent c720005 commit 607d32e56a70455ab3fa2365b5d9fafa4a524685 @jashkenas committed
Showing with 6 additions and 6 deletions.
  1. +6 −6 lib/services/base.rb
View
12 lib/services/base.rb
@@ -7,27 +7,27 @@ def get_json(url)
begin
JSON.parse(RestClient.get(URI.encode(url)))
rescue JSON::ParserError => e # Faux-log any failed requests.
- @data['failed_requests'] ||= []
- @data['failed_requests'] << url
+ Rails.logger.warn("Failed to parse json for: #{url}")
+ Rails.logger.warn(e.message)
{}
end
end
# Ensure that a failed api call doesn't screw up the remainder of our data.
def safe_request(title, opts={})
- RAILS_DEFAULT_LOGGER.info "starting: #{title}"
+ Rails.logger.info "starting: #{title}"
result = {}
return result if opts.has_key?(:ensure) && !opts[:ensure]
begin
result = yield
- RAILS_DEFAULT_LOGGER.info "done with: #{title}"
+ Rails.logger.info "done with: #{title}"
rescue RestClient::Exception => e
result = {}
- RAILS_DEFAULT_LOGGER.info "error for: #{title} ... #{e}"
+ Rails.logger.info "error for: #{title} ... #{e}"
end
result
end
end
-end
+end

0 comments on commit 607d32e

Please sign in to comment.
Something went wrong with that request. Please try again.