From: Brian Candler Date: 2012-10-25T04:44:21+09:00 Subject: Re: Exception handelling in ruby Joel Pearson wrote in post #1080729: > rescue => e > This rescues any error and lets you use 'e' as a variable to inspect the > error. That is incorrect. rescue => e only rescues exceptions which are StandardError and its descendants. That is, it is exactly the same as rescue StandardError => e > something like the below would catch errors 1 and 2 respectively, and if > the error didn't fall into those categories then the third rescue would > catch it. > > rescue 1 > rescue 2 > rescue No, a bare "rescue" also only captures StandardError and its children. If you want to rescue *absolutely every* exception then you need to write explicitly: rescue Exception However, as I said before, this is almost always a bad idea, because exceptions outside of StandardError are things you rarely want to catch; things that mean your interpreter has blown up in such a bad way that it's pointless attempting to continue, and catching it will only prolong the pain. -- Posted via http://www.ruby-forum.com/.