How to crash Ruby

January 3rd 2007 | Tags: programming ruby
  class BrokenError < StandardError
    def backtrace

  rescue e
    puts 'rescued'

Because of the exception in the backtrace generation, processing just dies. If you have an at_exit block, it will still be run, so I suppose I'm not really crashing the ruby interpreter, I suppose, but it comes close.

Found this one out migrating a rails app from 1.1.6 to 1.2. Instead of doing this:

  render 'controller/action'

the deprecation warning suggests the following:

  render :file => 'controller/action'

Unfortunately, this causes the error if you're still trying to run in 1.1.6. A more complete fix is to make sure to add use_full_path to the render call to prevent an older TemplateError from horking, like so:

  render :file => 'controller/action', :use_full_path => true

blog comments powered by Disqus