Robert Klemme wrote:
> 2008/10/1 Thomas B. <tpreal / gmail.com>:
>> Nit Khair wrote:
>>> Now in real life, "@test = " calls a method elsewhere which may call
>>> other methods. So i am clueless as to where the error actually is.
>>
>> You caused another exception inside your ensure clause, so the previous
>> one got lost, so that's your mistake. If you want the original exception
>> to live to tell the tale, you cannot raise another in your ensure
>> clause. But if your ensure clause was correct, there wouldn't be any
>> problems with handling correctly the original exception.
> 

I am not following you. How have i caused another exception in the 
ensure clause. I am not raising an exception in the ensure. The ensure 
clause only has some statement to free resources. as in :


begin
my_form = create_....

ensure
my_form.free_form.
...
end


In the example i gave you, the stderr.print is printing the error from 
above, but in my original ncurses program, it seems to directly go to 
the ensure.

Let's say in my ensure I said:

  my_form.free_form if !my_form.nil?
then the program would just terminate silently.


> Adding to that: an uninitialized variable does not cause a syntax
> error.  IIRC initially this was about a syntax error.
> 

Okay, i was trying to give you a simple example. Sometimes it is a 
variable - i may misspell it, or in some cases it is a syntax error.

Even currently as I am refactoring my code, I am sometimes getting the 
correct error, sometimes I have to comment out "ensure" to get the 
error.

> Cheers
> 
> robert

Perhaps I should ask the question differently. Am i doing something 
wrong, am i using the ensure clause incorrectly (the samples I started 
with released these structures in the ensure). This is my first major 
ruby app.
Thanks a lot for your time, Robert!
-- 
Posted via http://www.ruby-forum.com/.