From: Davide Benini Date: 2008-09-11T16:41:08+09:00 Subject: Re: How to check if a webpage exists >> require 'open-uri'; begin; open('http://www.www.www') {} rescue '404 >> error'; end Thanks folks, your suggestion works, but I am not able to integrate it with my existing code; I have some problems understanding how rescue interacts with code blocks. Basically, I have a chunk of code that must be executed ONLY IF there is no exception; if there is an exception, I need to execute another chunk of code. I tried a couple of syntaxes: require 'open-uri'; begin open('http://www.www.www') { // code to execute if everythinkg's ok } rescue '404 error' // code to execute in case of error end I also tried require 'open-uri'; begin open('http://www.www.www') {} rescue '404 error' // code to execute in case of error else // code to execute if everythinkg's ok end Also require 'open-uri'; begin open('http://www.www.www') puts "ok" rescue '404 error' puts "error" end None of this works. Which is the proper syntax? Davide -- Posted via http://www.ruby-forum.com/.