this loop brakes when i get the (SocketError)... i get errors because of
bad connection to my wireless network... i dont know how to handle this
error and keep the script from crashing...
this loop brakes when i get the (SocketError)... i get errors because of
bad connection to my wireless network... i dont know how to handle this
error and keep the script from crashing...
this loop brakes when i get the (SocketError)... i get errors because of
bad connection to my wireless network... i dont know how to handle this
error and keep the script from crashing...
Try this:
loop do
begin
res = Net::HTTP.get_response(URI.parse("http://bigmac.t35.com/text.txt
"))
print res.body
rescue SocketError => se
puts "Got socket error: #{se}"
end
sleep 3
end
i dont know how to handle this error and keep the script from crashing.
As already mentioned here (and code provided above), one strategy is to
use
begin/rescue:
begin
some_code_here_which_can_sometimes_fail
rescue # or rescue specific errors like LoadError... or in more
# general rescue Exception => e; pp e
# ^^^ is what I often do when i just quickly want to get info. i
love pp
end