merb-core 1.0.6 → 1.0.6.1
Sign up to get free protection for your applications and to get access to all the features.
@@ -1,118 +1,120 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
module DefaultExceptionHelper
|
5
|
-
|
6
|
-
# :api: private
|
7
|
-
def humanize_exception(e)
|
8
|
-
e.class.name.split("::").last.gsub(/([a-z])([A-Z])/, '\1 \2')
|
9
|
-
end
|
10
|
-
|
1
|
+
Merb::BootLoader.after_app_loads do
|
2
|
+
module Merb
|
3
|
+
class Dispatcher
|
11
4
|
# :api: private
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
"<h2>Sorry about that...</h2>"
|
5
|
+
module DefaultExceptionHelper
|
6
|
+
|
7
|
+
# :api: private
|
8
|
+
def humanize_exception(e)
|
9
|
+
e.class.name.split("::").last.gsub(/([a-z])([A-Z])/, '\1 \2')
|
18
10
|
end
|
19
|
-
end
|
20
11
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
location = match[3]
|
27
|
-
if filename.index(Merb.framework_root) == 0
|
28
|
-
type = "framework"
|
29
|
-
shortname = Pathname.new(filename).relative_path_from(Pathname.new(Merb.framework_root))
|
30
|
-
elsif filename.index(Merb.root) == 0
|
31
|
-
type = "app"
|
32
|
-
shortname = Pathname.new(filename).relative_path_from(Pathname.new(Merb.root))
|
33
|
-
elsif path = Gem.path.find {|p| filename.index(p) == 0}
|
34
|
-
type = "gem"
|
35
|
-
shortname = Pathname.new(filename).relative_path_from(Pathname.new(path))
|
12
|
+
# :api: private
|
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>"
|
36
17
|
else
|
37
|
-
|
38
|
-
shortname = filename
|
18
|
+
"<h2>Sorry about that...</h2>"
|
39
19
|
end
|
40
|
-
[type, shortname, filename, lineno, location]
|
41
|
-
else
|
42
|
-
['', '', '', nil, nil]
|
43
20
|
end
|
44
|
-
end
|
45
21
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
22
|
+
# :api: private
|
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
|
57
45
|
end
|
58
|
-
|
59
|
-
|
46
|
+
|
47
|
+
# :api: private
|
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")
|
60
65
|
end
|
61
|
-
ret << " </tbody>"
|
62
|
-
ret << "</table>"
|
63
|
-
ret.join("\n")
|
64
|
-
end
|
65
66
|
|
66
|
-
|
67
|
-
|
68
|
-
|
67
|
+
def jar?(filename)
|
68
|
+
filename.match(/jar\!/)
|
69
|
+
end
|
69
70
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
71
|
+
# :api: private
|
72
|
+
def textmate_url(filename, line)
|
73
|
+
"<a href='txmt://open?url=file://#{filename}&line=#{line}'>#{line}</a>"
|
74
|
+
end
|
74
75
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
76
|
+
# :api: private
|
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>"
|
82
83
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
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")
|
89
95
|
end
|
90
|
-
str << "</div></td>"
|
91
|
-
ret << str
|
92
|
-
ret << "</tr>"
|
93
|
-
ret.join("\n")
|
94
|
-
end
|
95
96
|
|
96
|
-
|
97
|
-
|
97
|
+
def jar?(filename)
|
98
|
+
filename.match(/jar\!/)
|
99
|
+
end
|
98
100
|
end
|
99
|
-
end
|
100
101
|
|
101
|
-
# :api: private
|
102
|
-
class DefaultException < Merb::Controller
|
103
|
-
self._template_root = File.dirname(__FILE__) / "views"
|
104
|
-
|
105
102
|
# :api: private
|
106
|
-
|
107
|
-
"
|
108
|
-
end
|
103
|
+
class DefaultException < Merb::Controller
|
104
|
+
self._template_root = File.dirname(__FILE__) / "views"
|
109
105
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
106
|
+
# :api: private
|
107
|
+
def _template_location(context, type = nil, controller = controller_name)
|
108
|
+
"#{context}.#{type}"
|
109
|
+
end
|
110
|
+
|
111
|
+
# :api: private
|
112
|
+
def index
|
113
|
+
@exceptions = request.exceptions
|
114
|
+
@show_details = Merb::Config[:exception_details]
|
115
|
+
render :format => :html
|
116
|
+
end
|
115
117
|
end
|
116
118
|
end
|
117
119
|
end
|
118
|
-
end
|
120
|
+
end
|
data/lib/merb-core/version.rb
CHANGED