Live data from Hacker News

Show HN: pry-rescue — workflow-optimized debugging for ruby

cirw.in

1–10 of 31 posts

Re: Show HN: pry-rescue — workflow-optimized debugging for ruby

#4
post #3
post #2

Thanks for this. How would I use it in Rails? Any tips for integration?

In rails you can just do: class ApplicationController I'm hoping to get a Rack middleware out at some point; which will make this even easier.

Here's a basic middleware...

  pry_rescue.rb
  require 'pry/rescue'
  class PryRescue
    def initialize(app)
      @app = app
    end

    def call(env)
      Pry::rescue{ @app.call(env) }
    end
  end
For rails you need to require the file and use the middleware...

  application.rb
  config.middleware.use "PryRescue"

Re: Show HN: pry-rescue — workflow-optimized debugging for ruby

#6
> Whenever an unhandled exception happens in your program, pry-rescue opens an interactive pry shell right at the point it was raised. Instead of glowering at a stack-trace spewed out by a dying process, you'll be engaging with your program as though it were still alive!

The pry console gives you access to the method that raised the exception, you can use it to inspect the values of variables (no more print statements!), the source code of methods (no more flapping around with a text editor!), and even move up and down the call stack (like a real debugger!).

Basically what we were doing in Smalltalk for decades and trying to tell people about. (To a remarkable degree of push-back and vitriol.) Many years ago, one of our community pointed out that while it lost out as a mainstream platform, Smalltalk actually won the war of ideas. (It's taking quite a long time for everyone else to catch up, however. People keep thinking they've gotten there when they're still a good 1/3rd short.)

Re: Show HN: pry-rescue — workflow-optimized debugging for ruby

#7

Are there any difference to https://github.com/pry/pry-exception_explorer ?

pry-rescue is a modernization thereof (banisterfiend helped me build it).

The only technical difference is that pry-rescue can catch exceptions raised at the C level (like NoMethodError, or ZeroDivisionError); but pry-rescue also has a much easier-to-learn API/UI. (Particularly, by only supporting catching unhandled exceptions, pry-rescue can avoid the need to predicate on which exceptions should be handled).

Re: Show HN: pry-rescue — workflow-optimized debugging for ruby

#9

Are there any difference to https://github.com/pry/pry-exception_explorer ?

Yes. Actually, pry-rescue not only imbibes pry-exception_explorer's power, but also provides its own possibilities. pry-rescue catches everything (even syntax errors).
Post reply on HN