From: Pen Ttt Date: 2010-08-27T18:58:29+09:00 Subject: error handling with exceptions in multi-thread download there are three program fragments,all of them have same problems, all of them can run ,but when i downloaded 30% data,an error ocurr undefined local variable or method `web' for Data:Class (NameError) cthreaddown is an array which contains many web. would you kind to tell me how to fix it? p1 [code] for page_to_fetch in cthreaddown threads< e puts "#{web} failed" rescue NameError => e puts "#{web} failed" rescue => e puts "#{web} failed" end } [/code] p2 [code] for page_to_fetch in cthreaddown threads< e puts "#{web} failed" rescue => e puts "#{web} wrong" end end end threads.each {|thr| thr.join } [/code] p3 [code] for page_to_fetch in cthreaddown threads< e puts "#{web} failed" rescue => e puts "#{web} wrong" end end end threads.each {|thr| begin thr.join rescue Timeout::Error => e puts "#{web} failed" rescue NameError => e puts "#{web} failed" rescue => e puts "#{web} failed" end } -- Posted via http://www.ruby-forum.com/.