lib/egregious.rb in egregious-0.2.1 vs lib/egregious.rb in egregious-0.2.2
- old
+ new
@@ -165,11 +165,11 @@
"\n\n" + exception.class.to_s + ' (' + exception.message.to_s + '):\n ' +
clean_backtrace(exception).join("\n ") +
"\n\n")
HoptoadNotifier.notify(exception) if defined?(HoptoadNotifier)
end
-
+
# override this if you want to change your respond_to behavior
def egregious_respond_to(exception)
respond_to do |format|
status = status_code_for_exception(exception)
format.xml { render :xml=> exception.to_xml, :status => status }
@@ -186,8 +186,27 @@
end
def self.included(base)
base.class_eval do
rescue_from 'Exception' , :with => :egregious_exception_handler
+
+ unless respond_to?(:flash)
+ def egregious_flash(exception)
+ end
+ end
+
+ unless respond_to?(:respond_to)
+ def egregious_respond_to(exception)
+ status = status_code_for_exception(exception)
+ case params[:format]
+ when 'xml' then render :xml=> exception.to_xml, :status => status
+ when 'json' then render :json=> exception.to_json, :status => status
+ # render the html page for the status we are returning it exists...if not then render the 500.html page.
+ else render :file => File.exists?(build_html_file_path(status)) ?
+ build_html_file_path(status) : build_html_file_path('500'),
+ :status => status
+ end
+ end
+ end
end
end
end