Re: "ensure" hiding actual error
- From: Glen Holcomb <damnbigman@xxxxxxxxx>
- Date: Wed, 1 Oct 2008 10:22:15 -0500
[Note: parts of this message were removed to make it a legal post.]
On Wed, Oct 1, 2008 at 9:08 AM, Nit Khair <sentinel.2001@xxxxxxx> wrote:
Robert Klemme wrote:
2008/10/1 Thomas B. <tpreal@xxxxxxxxx>:
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
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.
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/.
--
"Hey brother Christian with your high and mighty errand, Your actions speak
so loud, I can't hear a word you're saying."
-Greg Graffin (Bad Religion)
.
- Follow-Ups:
- Re: "ensure" hiding actual error
- From: Nit Khair
- Re: "ensure" hiding actual error
- References:
- "ensure" hiding actual error
- From: Nit Khair
- Re: "ensure" hiding actual error
- From: Robert Klemme
- Re: "ensure" hiding actual error
- From: Nit Khair
- Re: "ensure" hiding actual error
- From: Robert Klemme
- Re: "ensure" hiding actual error
- From: Nit Khair
- Re: "ensure" hiding actual error
- From: Thomas B.
- Re: "ensure" hiding actual error
- From: Robert Klemme
- Re: "ensure" hiding actual error
- From: Nit Khair
- "ensure" hiding actual error
- Prev by Date: Re: Non blocking socket keep blocking on read ?
- Next by Date: Remotely passing value on system() or %x[]
- Previous by thread: Re: "ensure" hiding actual error
- Next by thread: Re: "ensure" hiding actual error
- Index(es):
Relevant Pages
|