I have a module in a lib/assets file as follows:
require 'net/http'
require 'cgi'
require 'json'
module FetchRec
rate.sample(5).each do |result|
begin
url = URI.parse("http://www.url.com/dprc=Y&item_id=#{result["item"]}")
rescue
next
end
r = JSON.parse(Net::HTTP.get_response(url).body)
end
When I start my server I get an exception: Syntax Error — “Invalid next”
How can I handle exceptions in this module, so that if a url is not valid, the json parse script will skip to the next url, and parse that?
try removing the begin rescue block and replace with