From: Nit Khair Date: 2008-10-02T00:32:04+09:00 Subject: Re: "ensure" hiding actual error Glen Holcomb wrote: > On Wed, Oct 1, 2008 at 9:08 AM, Nit Khair wrote: > >> >> problems with handling correctly the original exception. >> ensure >> my_form.free_form. >> ... >> end >> > > What happens here if my_form never got a value because there was an > error > previous that made create_... invalid? > > What Thomas is saying is that there is an exception being raised by the > code > present in your ensure block. > > Fine. I get that. So is there a better or correct way of doing this so that I get the original error that was raised. Aaaah. so you mean if i check for my_form before freeing, then ... since no new exception is raised, the original exception will be displayed. So I _should_ say: ensure if !my_form.nil? my_form.free ... etc end -- Posted via http://www.ruby-forum.com/.