def errors_with_message(pattern)
# Generate an anonymous "matcher module" with a custom threequals
m = Module.new
(class << m; self; end).instance_eval do
define_method(:===) do |e|
pattern === e.message
end
end
m
end

puts "About to raise"

begin
raise "Timeout while reading from socket"
rescue errors_with_message(/socket/)
puts "Ignoring socket error"
end
puts "Continuing..."

This is mainly used for "===" overloading when rescue would perform
matching .

That is far thing for me. can anyone help me to understand what the "def
... end" part is doing?

I am totally uncomfortable with the syntax. So break it and help me to
understand what is doing.

-- 
Posted via http://www.ruby-forum.com/.