From: Daniel Schierbeck Date: 2006-05-19T02:18:42+09:00 Subject: Re: Rescue clauses on do/end blocks? Ross Bamford wrote: > Does that mean that with the proposed syntax, to rescue an exception > from this File.open, we'd have to use: > > begin > File.open('somefile') do |f| > puts f.read > rescue > # exception from f.read > end > rescue > # exception from File.open > end As I imagine it right now, rescue clauses on do/end blocks would only rescue exceptions raised *inside* that block -- to rescue exceptions raised with the method the block is attached to, one must wrap the method with begin/end. >> But I like the devil's advocate approach, it makes the proposals sharper :) > > :) In truth, I think I'm in favour of this change, especially if it > could be done so that the rescue catches exceptions from the block _as > well_ as those from the method to which the block is attached (if any). I'm not sure I'd like that -- I see a block attached to a method call as being, in some sense, a child of that call, another kind of argument if you will; having the child rescue exceptions raised by the parent seems unintuitive to me, though others may feel different. People, feel free to chime in. Daniel