Forum: Ruby find some error with exception

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Searchsa Faust (Guest)
on 2006-05-24 12:41
run following script
---------------------------------------------
def foo(i)
    foo(i+1)
end
def main1
    begin
        foo(1)
    rescue
        puts $!.backtrace.join("\n")
    end
end

def main2
    begin
        foo(1)
    rescue
        puts $!.backtrace.join("\n")
    end
end

main1
main2
----------------------------------------------
this will has to "stack too deep" error at DIFFERENT line of the script
but the result will be
===========================
mm.rb:2:in `foo'
mm.rb:2:in `foo'
mm.rb:8:in `main1'
mm.rb:22
mm.rb:2:in `foo'
mm.rb:2:in `foo'
mm.rb:8:in `main1'
mm.rb:22
===========================
both show the 1st error position
this error should be correct
Tim B. (Guest)
on 2006-05-24 13:29
(Received via mailing list)
What are you trying to accomplish? Infinite recursion is generally not
a really good idea unless you want to cripple your machine
temporarily.
   -tim
ts (Guest)
on 2006-05-24 13:59
(Received via mailing list)
>>>>> "T" == Tim B. <removed_email_address@domain.invalid> writes:

T> What are you trying to accomplish?

 Read *carefully* his message.

>> main1
   ^^^^^
>> main2
   ^^^^^

>> mm.rb:8:in `main1'
               ^^^^^
>> mm.rb:8:in `main1'
               ^^^^^

 In NODE_RESCUE, ruby_errinfo is reset to Qnil (well to e_info) but the
 backtrace is not reset, this is why ruby not rebuild it.




Guy Decoux
This topic is locked and can not be replied to.