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 ?
on 2005-12-13 01:24
on 2005-12-13 01:53
This same question was asked yesterday, search archives. The basic idea is to use rescue_action method. Kent.
on 2005-12-13 02:06
Kent S. 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?