(this is in the context of Rails, buts its primarily a Ruby question
dealing with exception handling)
This is driving me nuts - I’m tracking down a bug in ActionPack that
causes rails to do a 500 error with no info, or when testing causes an
immediate exit with no information or stack trace.
I’ve tracked it down to ActionView::TemplateError, where numerous
things can happen that cause an exception to be thrown from w/o the
TemplateError. For instance, the following controller will cause the
error to happen:
class FooController < ApplicationController
render :file => “unknown”, :use_full_path => false
And I cannot get the exception to be caught in a test case, no matter
what I do. For example, w/i a standard FooControllerTest:
assert_raises ActionController::MissingTemplate do
rescue Exception => e
This just exits - no flunk msg, assert_raise doesn’t catch, nothing.
I also commented out an “ensure” in ActionController::Base#process, to
make sure that wouldn’t halt the exception. It still exits.
I tracked it down into TemplateError via a lot of tedious logging, and
it seems the line here throws an error (though I cant figure out why,
it works in irb):
and this line can also throw an exception, which makes sense because
@file_name refers to a non-existent file:
And of course none of that answers why I can’t rescue the exception
back in my calling code, no matter what I do. Any ideas?