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 ? -- Posted via http://www.ruby-forum.com/.
This same question was asked yesterday, search archives. The basic idea is to use rescue_action method. Kent. On Monday 12 December 2005 18:24, List Recv wrote:> 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 ?
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? -- Posted via http://www.ruby-forum.com/.