$DEBUG and exceptions

What’s the rationale for debug mode echoing all those exceptions to
stderr? That makes me want to avoid either using exceptions as a control
structure or using $DEBUG…

Joel VanderWerf wrote:

What’s the rationale for debug mode echoing all those exceptions to
stderr? That makes me want to avoid either using exceptions as a control
structure or using $DEBUG…

Maybe it’s not clear that I meant handled exceptions, as in the
following. Why would I want to know all the exceptions that were raised,
unless they were uncaught?

$DEBUG=true
10.times do |i|
begin
raise “#{i}”
rescue StandardError
end
end

puts “Done!”

Joel VanderWerf vjoel@PATH.Berkeley.EDU writes:

Joel VanderWerf wrote:

What’s the rationale for debug mode echoing all those exceptions to
stderr? That makes me want to avoid either using exceptions as a
control structure or using $DEBUG…

Maybe it’s not clear that I meant handled exceptions, as in the
following. Why would I want to know all the exceptions that were
raised, unless they were uncaught?

$DEBUG=true
10.times do |i|
begin
raise “#{i}”
rescue StandardError
end
end

puts “Done!”

If you look at the ruby source, $DEBUG does only 2 things:

- prints out exceptions when they happen
- act as if Thread.abort_on_exception = true, even if it isn't.

If you don’t like the first, just set Thread.abort_on_exception to
true. :wink:

Matt Armstrong wrote:

If you look at the ruby source, $DEBUG does only 2 things:

- prints out exceptions when they happen
- act as if Thread.abort_on_exception = true, even if it isn't.

If you don’t like the first, just set Thread.abort_on_exception to
true. :wink:

Ah, I was overestimating the functionality of $DEBUG. I have
Thread.abort_on_exception = true anyway, so I’ll just turn off $DEBUG.

Thanks!