Full stracktrace in ruby 1.9

Discussion in 'Ruby' started by Freak Guard, Sep 25, 2009.

  1. Freak Guard

    Freak Guard Guest

    I'm getting stacktraces like:

    expected Foo, got #<NoMethodError: undefined method `bar=' for
    nil:NilClass>
    spec/models/foobar_spec.rb:79:in `block (6 levels) in <top (required)>'

    but it would be way more useful to get the 6 levels. How to enable that
    globally?
    --
    Posted via http://www.ruby-forum.com/.
    Freak Guard, Sep 25, 2009
    #1
    1. Advertising

  2. Freak Guard

    Roger Pack Guest

    Freak Guard wrote:
    > I'm getting stacktraces like:
    >
    > expected Foo, got #<NoMethodError: undefined method `bar=' for
    > nil:NilClass>
    > spec/models/foobar_spec.rb:79:in `block (6 levels) in <top (required)>'
    >
    > but it would be way more useful to get the 6 levels. How to enable that
    > globally?


    add this somewhere:


    at_exit {
    puts "==== "
    puts $!.backtrace.join("\n")
    puts "===="
    }

    Though there are other options [1]

    http://github.com/rogerdpack/ruby_backtracer/blob/master/backtrace_nothing_swallowed.rb
    --
    Posted via http://www.ruby-forum.com/.
    Roger Pack, Sep 25, 2009
    #2
    1. Advertising

  3. On 25.09.2009 16:40, Roger Pack wrote:
    > Freak Guard wrote:
    >> I'm getting stacktraces like:
    >>
    >> expected Foo, got #<NoMethodError: undefined method `bar=' for
    >> nil:NilClass>
    >> spec/models/foobar_spec.rb:79:in `block (6 levels) in <top (required)>'
    >>
    >> but it would be way more useful to get the 6 levels. How to enable that
    >> globally?

    >
    > add this somewhere:
    >
    >
    > at_exit {
    > puts "==== "
    > puts $!.backtrace.join("\n")
    > puts "===="
    > }
    >
    > Though there are other options [1]
    >
    > http://github.com/rogerdpack/ruby_backtracer/blob/master/backtrace_nothing_swallowed.rb


    You could simply wrap the whole script or the offending region in begin
    rescue.

    robert


    --
    remember.guy do |as, often| as.you_can - without end
    http://blog.rubybestpractices.com/
    Robert Klemme, Sep 25, 2009
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Samuel R. Neff
    Replies:
    2
    Views:
    583
    bradley
    Jun 10, 2005
  2. Randy Lawrence

    Full-featured untaint() method for Ruby?

    Randy Lawrence, Jun 21, 2004, in forum: Ruby
    Replies:
    8
    Views:
    314
    Paul Brannan
    Jun 22, 2004
  3. Vincent Fourmond

    Ruby-full debian package

    Vincent Fourmond, Dec 22, 2006, in forum: Ruby
    Replies:
    8
    Views:
    114
    Vincent Fourmond
    Dec 29, 2006
  4. Replies:
    1
    Views:
    165
    Ken Bloom
    May 28, 2007
  5. sur
    Replies:
    1
    Views:
    78
    Nit Khair
    Nov 4, 2008
Loading...

Share This Page