| Module | Merb::Dispatcher::DefaultExceptionHelper |
| In: |
merb-core/lib/merb-core/dispatch/default_exception/default_exception.rb
|
:api: private
:api: private
# File merb-core/lib/merb-core/dispatch/default_exception/default_exception.rb, line 13
13: def error_codes(exception)
14: if @show_details
15: message, message_details = exception.message.split("\n", 2)
16: "<h2>#{escape_html(message)}</h2><p>#{escape_html(message_details)}</p>"
17: else
18: "<h2>Sorry about that...</h2>"
19: end
20: end
:api: private
# File merb-core/lib/merb-core/dispatch/default_exception/default_exception.rb, line 23
23: def frame_details(line)
24: if (match = line.match(/^(.+):(\d+):(.+)$/))
25: filename = match[1]
26: lineno = match[2]
27: location = match[3]
28: if filename.index(Merb.framework_root) == 0
29: type = "framework"
30: shortname = Pathname.new(filename).relative_path_from(Pathname.new(Merb.framework_root))
31: elsif filename.index(Merb.root) == 0
32: type = "app"
33: shortname = Pathname.new(filename).relative_path_from(Pathname.new(Merb.root))
34: elsif path = Gem.path.find {|p| filename.index(p) == 0}
35: type = "gem"
36: shortname = Pathname.new(filename).relative_path_from(Pathname.new(path))
37: else
38: type = "other"
39: shortname = filename
40: end
41: [type, shortname, filename, lineno, location]
42: else
43: ['', '', '', nil, nil]
44: end
45: end
:api: private
# File merb-core/lib/merb-core/dispatch/default_exception/default_exception.rb, line 8
8: def humanize_exception(e)
9: e.class.name.split("::").last.gsub(/([a-z])([A-Z])/, '\1 \2')
10: end
# File merb-core/lib/merb-core/dispatch/default_exception/default_exception.rb, line 67
67: def jar?(filename)
68: filename.match(/jar\!/)
69: end
# File merb-core/lib/merb-core/dispatch/default_exception/default_exception.rb, line 97
97: def jar?(filename)
98: filename.match(/jar\!/)
99: end
:api: private
# File merb-core/lib/merb-core/dispatch/default_exception/default_exception.rb, line 48
48: def listing(key, value, arr)
49: ret = []
50: ret << "<table class=\"listing\" style=\"display: none\">"
51: ret << " <thead>"
52: ret << " <tr><th width='25%'>#{key}</th><th width='75%'>#{value}</th></tr>"
53: ret << " </thead>"
54: ret << " <tbody>"
55: (arr || []).each_with_index do |(key, val), i|
56: klass = i % 2 == 0 ? "even" : "odd"
57: ret << " <tr class=\"#{klass}\"><td>#{key}</td><td>#{val.inspect}</td></tr>"
58: end
59: if arr.blank?
60: ret << " <tr class='odd'><td colspan='2'>None</td></tr>"
61: end
62: ret << " </tbody>"
63: ret << "</table>"
64: ret.join("\n")
65: end
:api: private
# File merb-core/lib/merb-core/dispatch/default_exception/default_exception.rb, line 77
77: def render_source(filename, line)
78: line = line.to_i
79: ret = []
80: ret << "<tr class='source'>"
81: ret << " <td class='collapse'></td>"
82: str = " <td class='code' colspan='2'><div>"
83:
84: __caller_lines__(filename, line, 5) do |lline, lcode|
85: str << "<a href='txmt://open?url=file://#{filename}&line=#{lline}'>#{lline}</a>"
86: str << "<em>" if line == lline
87: str << Erubis::XmlHelper.escape_xml(lcode)
88: str << "</em>" if line == lline
89: str << "\n"
90: end
91: str << "</div></td>"
92: ret << str
93: ret << "</tr>"
94: ret.join("\n")
95: end