[#604] Add nicer error formatting, similar to the old style
This commit is contained in:
parent
fe6a79ac17
commit
994132a51a
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue