[#604] Add nicer error formatting, similar to the old style

This commit is contained in:
Holger Just 2011-10-17 18:47:13 +02:00
parent fe6a79ac17
commit 994132a51a
1 changed files with 11 additions and 0 deletions

View File

@ -4,9 +4,20 @@ module ChiliProject
module Context
def self.included(base)
base.send(:include, InstanceMethods)
base.class_eval do
alias_method_chain :handle_error, :formatting
end
end
module InstanceMethods
def handle_error_with_formatting(e)
error = handle_error_without_formatting(e)
escaped_error = registers[:view].send(:h, error) rescue CGI::escapeHTML(error)
html = '<div class="flash error">' + escaped_error + '</div>'
html_result(html)
end
def html_result(html)
key = nil
while key.nil? || html_results.has_key?(key)