Forum: Ruby on Rails What happen when a controller raises a custom exception ?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
4349a46c5faf5658a7240c22b3c4c21f?d=identicon&s=25 Bob Mundane (pgs)
on 2009-02-16 12:20
Hello, some controllers of mine raises security exception.

environments/test.rb defines
 config.action_controller.consider_all_requests_local = true

1) I want to raise from a controller, and have the exception visible in
test, inside assert_raise blocks but I don't.

2) I defined rescue_action_in_public() which (I'm sure) is not called
during tests.

3) But during tests, when my controller raises
AppException::SecurityError it is not caught by the assert_raise block.

So I added this, to see what happens :

def rescue_action_locally(exception)
  p exception
  raise exception

The exception is well printed on console but re-raising lead to Class:
Message: <"You have a nil object when you didn't expect it!\nYou might
have expected an instance of ActiveRecord::Base.\nThe error occurred
while evaluating nil.[]=">

I really don't understand what happen because after re-raising no code
of mine is running, it leave my scope ...

So I wonder how to have these exceptions visible in test ?

D69d23d8e811e8ab2a8593380d6ede63?d=identicon&s=25 Jeff Emminger (jemminger)
on 2009-02-17 01:17
(Received via mailing list)
Try rescue_from:

On Feb 16, 6:20 am, Bob Mundane <>
This topic is locked and can not be replied to.