Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Syntax errors are concealed #31

mfn opened this Issue · 2 comments

3 participants

mfn commented

Running rescue on a script with an syntax error conceals the real error:

$ cat script.rb 
$ ruby -c script.rb                                                                                                
script.rb:1: syntax error, unexpected $end
$ rescue script.rb 
/data/users/mfn/.rvm/gems/ruby-1.9.3-p392/gems/pry-rescue-1.0.0/lib/pry-rescue.rb:169:in `+': can't convert nil into Array (TypeError)
        from /data/users/mfn/.rvm/gems/ruby-1.9.3-p392/gems/pry-rescue-1.0.0/lib/pry-rescue.rb:169:in `without_duplicates'
        from /data/users/mfn/.rvm/gems/ruby-1.9.3-p392/gems/pry-rescue-1.0.0/lib/pry-rescue.rb:54:in `enter_exception_context'
        from /data/users/mfn/.rvm/gems/ruby-1.9.3-p392/gems/pry-rescue-1.0.0/lib/pry-rescue/core_ext.rb:38:in `rescued'
        from /data/users/mfn/.rvm/gems/ruby-1.9.3-p392/gems/pry-rescue-1.0.0/lib/pry-rescue/core_ext.rb:18:in `rescue in block (2 levels) in rescue'
        from /data/users/mfn/.rvm/gems/ruby-1.9.3-p392/gems/pry-rescue-1.0.0/lib/pry-rescue/core_ext.rb:15:in `block (2 levels) in rescue'
        from /data/users/mfn/.rvm/gems/ruby-1.9.3-p392/gems/pry-rescue-1.0.0/lib/pry-rescue/core_ext.rb:13:in `catch'
        from /data/users/mfn/.rvm/gems/ruby-1.9.3-p392/gems/pry-rescue-1.0.0/lib/pry-rescue/core_ext.rb:13:in `block in rescue'
        from /data/users/mfn/.rvm/gems/ruby-1.9.3-p392/gems/pry-rescue-1.0.0/lib/pry-rescue/core_ext.rb:12:in `loop'
        from /data/users/mfn/.rvm/gems/ruby-1.9.3-p392/gems/pry-rescue-1.0.0/lib/pry-rescue/core_ext.rb:12:in `rescue'
        from /data/users/mfn/.rvm/gems/ruby-1.9.3-p392/gems/pry-rescue-1.0.0/lib/pry-rescue.rb:72:in `load'
        from /data/users/mfn/.rvm/gems/ruby-1.9.3-p392/gems/pry-rescue-1.0.0/bin/rescue:42:in `<top (required)>'
        from /data/users/mfn/.rvm/gems/ruby-1.9.3-p392/bin/rescue:19:in `load'
        from /data/users/mfn/.rvm/gems/ruby-1.9.3-p392/bin/rescue:19:in `<main>'
        from /data/users/mfn/.rvm/gems/ruby-1.9.3-p392/bin/ruby_noexec_wrapper:14:in `eval'
        from /data/users/mfn/.rvm/gems/ruby-1.9.3-p392/bin/ruby_noexec_wrapper:14:in `<main>'

A simple workaround at the shell level is easily possible: ruby -c script.rb && rescue script.rb.

But maybe there's also a nice way to make rescue more robust in this regard.

@rking rking referenced this issue from a commit
@rking rking Start of fix for #31; needs work 284ed63

@ConradIrwin - I didn't finish this, because I'm barely propping up my eyelids. It's maybe a start?:

@ConradIrwin ConradIrwin closed this issue from a commit
@ConradIrwin Rely on nil check in Pry.rescued [Closes #31]
Post recent refactoring, it should not be possible for
enter_exception_context to be called with an invalid exception.

`rake sintax` now does this:

This should now open a pry console just like any other error, please let me know if you're still having difficulties.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.