Forum: Ruby on Rails How do I catch an ActionController Error?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ccfe7d097475a32dc3ff78d6fc42c852?d=identicon&s=25 List Recv (lstrecv)
on 2005-12-13 00:24
I can't figure out how to have an ActionController catch it's own
exceptions.

For instance:

  def thankyou
  	begin
  		render  'nonexistentjustwanttoseetheexceptionthrownthankyou'
  	rescue ActionController::ActionControllerError => exc
  		render :text => exc.to_yaml
  	rescue Exception => exc
  		render :text => exc.to_yaml
  	end
  end

get's name errors - it seems that ActionController's own exceptions
aren't defined within its class!!! How do I solve this?

PS Also, how do I html escape text that I want to render using render
:text ?
3ccecc71b9fb0a3d7f00a0bef6f0a63a?d=identicon&s=25 Kent Sibilev (Guest)
on 2005-12-13 00:53
(Received via mailing list)
This same question was asked yesterday, search archives. The basic idea
is to
use rescue_action method.

Kent.
Ccfe7d097475a32dc3ff78d6fc42c852?d=identicon&s=25 List Recv (lstrecv)
on 2005-12-13 01:06
Kent Sibilev wrote:
> This same question was asked yesterday, search archives. The basic idea
> is to
> use rescue_action method.
>
> Kent.

Got it.  Thanks.

However, the solution there won't work for me, as I'd like to catch them
within the actual actions, as opposed to in a general method per
controller.

Could you explain to me why those constants (ie, the AC exception
classes) aren't defined - shouldn't they have been defined when
action_controller.rb was included? - and how I can define them?

I'm assuming that, if I were to define them, I could then catch them
within my action methods.  Is this true?
This topic is locked and can not be replied to.