2009-05-15 20:49:11 -04:00
|
|
|
module ActionController #:nodoc:
|
|
|
|
module Rescue
|
2009-05-28 12:35:36 -04:00
|
|
|
extend ActiveSupport::Concern
|
2009-09-15 11:05:46 -04:00
|
|
|
include ActiveSupport::Rescuable
|
2009-05-15 20:49:11 -04:00
|
|
|
|
2010-07-19 08:49:20 -04:00
|
|
|
def rescue_with_handler(exception)
|
2010-07-19 12:03:20 -04:00
|
|
|
if (exception.respond_to?(:original_exception) &&
|
|
|
|
(orig_exception = exception.original_exception) &&
|
|
|
|
handler_for_rescue(orig_exception))
|
2010-07-19 08:49:20 -04:00
|
|
|
exception = orig_exception
|
|
|
|
end
|
|
|
|
super(exception)
|
|
|
|
end
|
|
|
|
|
2009-05-28 10:49:02 -04:00
|
|
|
private
|
2009-09-15 11:05:46 -04:00
|
|
|
def process_action(*args)
|
2009-05-28 10:49:02 -04:00
|
|
|
super
|
|
|
|
rescue Exception => exception
|
2009-09-15 11:05:46 -04:00
|
|
|
rescue_with_handler(exception) || raise(exception)
|
2009-05-28 10:49:02 -04:00
|
|
|
end
|
2009-05-15 20:49:11 -04:00
|
|
|
end
|
|
|
|
end
|