>>>>> "a" == aschneiderman  <aschneiderman / my-deja.com> writes:

a> testerror.rb:3: undefined local variable or method `ddddd' for
a> Object:0x45aa5c0> (NameError)

 By default 'rescue'  catch only StandardError.

 With ruby 1.6, ScriptError is now a subclass of Exception.

    * Exception
        * fatal
        * Interrupt
        * NoMemoryError
        * ScriptError
            * LoadError
            * NameError
            * NotImplementedError
            * SyntaxError
        * SignalException
        * StandardError
            * ArgumentError
            * IndexError
            * IOError
                * EOFError
            * LocalJumpError
            * RangeError
                * FloatDomainError
            * RegexpError
            * RuntimeError
            * SecurityError
            * SystemCallError
            * SystemStackError
            * ThreadError
            * TypeError
            * ZeroDivisionError
        * SystemExit

 You can write:

    begin
       print "this is a test"
       ddddd
    rescue => detail
       print "I ran into an error:\n"
       print detail.backtrace.join("\n")
    rescue NameError => detail
       puts "Here : #{detail} at #{detail.backtrace}"
    end


Guy Decoux