/usr/lib/ruby/vendor_ruby/merb-core/dispatch/default_exception/default_exception.rb is in ruby-merb-core 1.1.3+dfsg-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | Merb::BootLoader.after_app_loads do
module Merb
class Dispatcher
# :api: private
module DefaultExceptionHelper
# :api: private
def humanize_exception(e)
e.class.name.split("::").last.gsub(/([a-z])([A-Z])/, '\1 \2')
end
# :api: private
def error_codes(exception)
if @show_details
message, message_details = exception.message.split("\n", 2)
"<h2>#{escape_html(message)}</h2><p>#{escape_html(message_details)}</p>"
else
"<h2>Sorry about that...</h2>"
end
end
# :api: private
def frame_details(line)
if (match = line.match(/^(.+):(\d+):(.+)$/))
filename = match[1]
lineno = match[2]
location = match[3]
if filename.index(Merb.framework_root) == 0
type = "framework"
shortname = Pathname.new(filename).relative_path_from(Pathname.new(Merb.framework_root))
elsif filename.index(Merb.root) == 0
type = "app"
shortname = Pathname.new(filename).relative_path_from(Pathname.new(Merb.root))
elsif Module.const_defined?(:Gem) && Gem.respond_to?(:path) && path = Gem.path.find {|p| filename.index(p) == 0}
type = "gem"
shortname = Pathname.new(filename).relative_path_from(Pathname.new(path))
else
type = "other"
shortname = filename
end
[type, shortname, filename, lineno, location]
else
['', '', '', nil, nil]
end
end
# :api: private
def listing(key, value, arr)
ret = []
ret << "<table class=\"listing\" style=\"display: none\">"
ret << " <thead>"
ret << " <tr><th width='25%'>#{key}</th><th width='75%'>#{value}</th></tr>"
ret << " </thead>"
ret << " <tbody>"
(arr || []).each_with_index do |(key, val), i|
klass = i % 2 == 0 ? "even" : "odd"
ret << " <tr class=\"#{klass}\"><td>#{key}</td><td>#{val.inspect}</td></tr>"
end
if arr.blank?
ret << " <tr class='odd'><td colspan='2'>None</td></tr>"
end
ret << " </tbody>"
ret << "</table>"
ret.join("\n")
end
def jar?(filename)
filename.match(/jar\!/)
end
# :api: private
def textmate_url(filename, line)
"<a href='txmt://open?url=file://#{filename}&line=#{line}'>#{line}</a>"
end
# :api: private
def render_source(filename, line)
line = line.to_i
ret = []
ret << "<tr class='source'>"
ret << " <td class='collapse'></td>"
str = " <td class='code' colspan='2'><div>"
__caller_lines__(filename, line, 5) do |lline, lcode|
str << textmate_url(filename, lline)
str << "<em>" if line == lline
str << Erubis::XmlHelper.escape_xml(lcode)
str << "</em>" if line == lline
str << "\n"
end
str << "</div></td>"
ret << str
ret << "</tr>"
ret.join("\n")
end
def jar?(filename)
filename.match(/jar\!/)
end
end
# :api: private
class DefaultException < Merb::Controller
self._template_root = File.dirname(__FILE__) / "views"
# :api: private
def _template_location(context, type = nil, controller = controller_name)
"#{context}.#{type}"
end
# :api: private
def index
@exceptions = request.exceptions
@show_details = Merb::Config[:exception_details]
render :format => :html
end
end
end
end
end
|