ultra-safe-rb 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/better_errors-2.10.1/CHANGELOG.md +3 -0
- data/better_errors-2.10.1/Gemfile +11 -0
- data/better_errors-2.10.1/LICENSE +22 -0
- data/better_errors-2.10.1/README.md +163 -0
- data/better_errors-2.10.1/better_errors.gemspec +48 -0
- data/better_errors-2.10.1/gemfiles/pry010.gemfile +10 -0
- data/better_errors-2.10.1/gemfiles/pry011.gemfile +9 -0
- data/better_errors-2.10.1/gemfiles/pry09.gemfile +9 -0
- data/better_errors-2.10.1/gemfiles/rack.gemfile +8 -0
- data/better_errors-2.10.1/gemfiles/rack_boc.gemfile +9 -0
- data/better_errors-2.10.1/gemfiles/rails42.gemfile +10 -0
- data/better_errors-2.10.1/gemfiles/rails42_boc.gemfile +11 -0
- data/better_errors-2.10.1/gemfiles/rails42_haml.gemfile +11 -0
- data/better_errors-2.10.1/gemfiles/rails50.gemfile +9 -0
- data/better_errors-2.10.1/gemfiles/rails50_boc.gemfile +10 -0
- data/better_errors-2.10.1/gemfiles/rails50_haml.gemfile +10 -0
- data/better_errors-2.10.1/gemfiles/rails51.gemfile +9 -0
- data/better_errors-2.10.1/gemfiles/rails51_boc.gemfile +10 -0
- data/better_errors-2.10.1/gemfiles/rails51_haml.gemfile +10 -0
- data/better_errors-2.10.1/gemfiles/rails52.gemfile +9 -0
- data/better_errors-2.10.1/gemfiles/rails52_boc.gemfile +10 -0
- data/better_errors-2.10.1/gemfiles/rails52_haml.gemfile +10 -0
- data/better_errors-2.10.1/gemfiles/rails60.gemfile +8 -0
- data/better_errors-2.10.1/gemfiles/rails60_boc.gemfile +9 -0
- data/better_errors-2.10.1/gemfiles/rails60_haml.gemfile +9 -0
- data/better_errors-2.10.1/gemfiles/rails61.gemfile +8 -0
- data/better_errors-2.10.1/gemfiles/rails61_boc.gemfile +9 -0
- data/better_errors-2.10.1/gemfiles/rails61_haml.gemfile +9 -0
- data/better_errors-2.10.1/lib/better_errors/code_formatter/html.rb +40 -0
- data/better_errors-2.10.1/lib/better_errors/code_formatter/text.rb +14 -0
- data/better_errors-2.10.1/lib/better_errors/code_formatter.rb +52 -0
- data/better_errors-2.10.1/lib/better_errors/editor.rb +103 -0
- data/better_errors-2.10.1/lib/better_errors/error_page.rb +169 -0
- data/better_errors-2.10.1/lib/better_errors/error_page_style.rb +43 -0
- data/better_errors-2.10.1/lib/better_errors/exception_extension.rb +17 -0
- data/better_errors-2.10.1/lib/better_errors/exception_hint.rb +29 -0
- data/better_errors-2.10.1/lib/better_errors/inspectable_value.rb +45 -0
- data/better_errors-2.10.1/lib/better_errors/middleware.rb +237 -0
- data/better_errors-2.10.1/lib/better_errors/rails.rb +28 -0
- data/better_errors-2.10.1/lib/better_errors/raised_exception.rb +89 -0
- data/better_errors-2.10.1/lib/better_errors/repl/basic.rb +20 -0
- data/better_errors-2.10.1/lib/better_errors/repl/pry.rb +88 -0
- data/better_errors-2.10.1/lib/better_errors/repl.rb +32 -0
- data/better_errors-2.10.1/lib/better_errors/stack_frame.rb +136 -0
- data/better_errors-2.10.1/lib/better_errors/templates/main.css +1 -0
- data/better_errors-2.10.1/lib/better_errors/templates/main.erb +431 -0
- data/better_errors-2.10.1/lib/better_errors/templates/text.erb +24 -0
- data/better_errors-2.10.1/lib/better_errors/templates/variable_info.erb +82 -0
- data/better_errors-2.10.1/lib/better_errors/version.rb +4 -0
- data/better_errors-2.10.1/lib/better_errors.rb +144 -0
- data/ultra-safe-rb.gemspec +12 -0
- metadata +92 -0
|
@@ -0,0 +1,431 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title><%= exception_type %> at <%= request_path %></title>
|
|
5
|
+
<link rel="icon" href="data:;base64,=" />
|
|
6
|
+
</head>
|
|
7
|
+
<body class="better-errors-javascript-not-loaded">
|
|
8
|
+
<%# Stylesheets are placed in the <body> for Turbolinks compatibility. %>
|
|
9
|
+
<%== ErrorPageStyle.style_tag(csp_nonce) %>
|
|
10
|
+
|
|
11
|
+
<%# IE8 compatibility crap %>
|
|
12
|
+
<script nonce="<%= csp_nonce %>">
|
|
13
|
+
(function() {
|
|
14
|
+
var elements = ["section", "nav", "header", "footer", "audio"];
|
|
15
|
+
for (var i = 0; i < elements.length; i++) {
|
|
16
|
+
document.createElement(elements[i]);
|
|
17
|
+
}
|
|
18
|
+
})();
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<%#
|
|
22
|
+
If Rails's Turbolinks is used, the Better Errors page is probably
|
|
23
|
+
rendered in the host app's layout. Let's empty out the styles of the
|
|
24
|
+
host app.
|
|
25
|
+
%>
|
|
26
|
+
<script nonce="<%= csp_nonce %>">
|
|
27
|
+
if (window.Turbolinks) {
|
|
28
|
+
for(var i=0; i < document.styleSheets.length; i++) {
|
|
29
|
+
if(document.styleSheets[i].href)
|
|
30
|
+
document.styleSheets[i].disabled = true;
|
|
31
|
+
}
|
|
32
|
+
if (window.Turbolinks.controller) {
|
|
33
|
+
// Turbolinks > 5 (see https://github.com/turbolinks/turbolinks/issues/6)
|
|
34
|
+
document.addEventListener("turbolinks:load", function restoreCSS(e) {
|
|
35
|
+
for(var i=0; i < document.styleSheets.length; i++) {
|
|
36
|
+
document.styleSheets[i].disabled = false;
|
|
37
|
+
}
|
|
38
|
+
document.removeEventListener("turbolinks:load", restoreCSS, false);
|
|
39
|
+
});
|
|
40
|
+
} else {
|
|
41
|
+
document.addEventListener("page:restore", function restoreCSS(e) {
|
|
42
|
+
for(var i=0; i < document.styleSheets.length; i++) {
|
|
43
|
+
document.styleSheets[i].disabled = false;
|
|
44
|
+
}
|
|
45
|
+
document.removeEventListener("page:restore", restoreCSS, false);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
</script>
|
|
50
|
+
|
|
51
|
+
<p class='no-inline-style-notice'>
|
|
52
|
+
<strong>
|
|
53
|
+
Better Errors can't apply inline style<span class='no-javascript-notice'> (or run Javascript)</span>,
|
|
54
|
+
possibly because you have a Content Security Policy along with Turbolinks.
|
|
55
|
+
But you can
|
|
56
|
+
<a href='/__better_errors' target="_blank">open the interactive console in a new tab/window</a>.
|
|
57
|
+
</strong>
|
|
58
|
+
</p>
|
|
59
|
+
|
|
60
|
+
<div class='top'>
|
|
61
|
+
<header class="exception">
|
|
62
|
+
<h2><strong><%= exception_type %></strong> <span>at <%= request_path %></span></h2>
|
|
63
|
+
<p><%= exception_message %></p>
|
|
64
|
+
<% unless active_support_actions.empty? %>
|
|
65
|
+
<div class='fix-actions'>
|
|
66
|
+
<% active_support_actions.each do |action, _| %>
|
|
67
|
+
<form class="button_to" method="post" action="<%= action_dispatch_action_endpoint %>">
|
|
68
|
+
<input type="submit" value="<%= action %>">
|
|
69
|
+
<input type="hidden" name="action" value="<%= action %>">
|
|
70
|
+
<input type="hidden" name="error" value="<%= exception_type %>">
|
|
71
|
+
<input type="hidden" name="location" value="<%= request_path %>">
|
|
72
|
+
</form>
|
|
73
|
+
<% end %>
|
|
74
|
+
</div>
|
|
75
|
+
<% end %>
|
|
76
|
+
<% if exception_hint %>
|
|
77
|
+
<h2>Hint: <%= exception_hint %></h2>
|
|
78
|
+
<% end %>
|
|
79
|
+
</header>
|
|
80
|
+
</div>
|
|
81
|
+
|
|
82
|
+
<section class="backtrace">
|
|
83
|
+
<nav class="sidebar">
|
|
84
|
+
<nav class="tabs">
|
|
85
|
+
<a href="#" id="application_frames">Application Frames</a>
|
|
86
|
+
<a href="#" id="all_frames">All Frames</a>
|
|
87
|
+
</nav>
|
|
88
|
+
<ul class="frames">
|
|
89
|
+
<% backtrace_frames.each_with_index do |frame, index| %>
|
|
90
|
+
<li class="<%= frame.context %>" data-context="<%= frame.context %>" data-index="<%= index %>">
|
|
91
|
+
<span class='stroke'></span>
|
|
92
|
+
<i class="icon <%= frame.context %>"></i>
|
|
93
|
+
<div class="info">
|
|
94
|
+
<div class="name">
|
|
95
|
+
<strong><%= frame.class_name %></strong><span class='method'><%= frame.method_name %></span>
|
|
96
|
+
</div>
|
|
97
|
+
<div class="location">
|
|
98
|
+
<span class="filename"><%= frame.pretty_path %></span>, line <span class="line"><%= frame.line %></span>
|
|
99
|
+
</div>
|
|
100
|
+
</div>
|
|
101
|
+
</li>
|
|
102
|
+
<% end %>
|
|
103
|
+
</ul>
|
|
104
|
+
</nav>
|
|
105
|
+
|
|
106
|
+
<div class="frameInfos">
|
|
107
|
+
<div class="frame_info current" data-frame-idx="0">
|
|
108
|
+
<p class='no-javascript-notice'>
|
|
109
|
+
Better Errors can't run Javascript here<span class='no-inline-style-notice'> (or apply inline style)</span>,
|
|
110
|
+
possibly because you have a Content Security Policy along with Turbolinks.
|
|
111
|
+
But you can
|
|
112
|
+
<a href='/__better_errors' target="_blank">open the interactive console in a new tab/window</a>.
|
|
113
|
+
</p>
|
|
114
|
+
<!-- this is enough information to show something in case JS doesn't get to load -->
|
|
115
|
+
<%== ErrorPage.render_template('variable_info', first_frame_variable_info) %>
|
|
116
|
+
</div>
|
|
117
|
+
</div>
|
|
118
|
+
</section>
|
|
119
|
+
</body>
|
|
120
|
+
<script nonce="<%= csp_nonce %>">
|
|
121
|
+
(function() {
|
|
122
|
+
|
|
123
|
+
var OID = "<%= id %>";
|
|
124
|
+
var csrfToken = "<%= csrf_token %>";
|
|
125
|
+
|
|
126
|
+
var previousFrame = null;
|
|
127
|
+
var allFrames = document.querySelectorAll("ul.frames li");
|
|
128
|
+
var frameInfos = document.querySelector(".frameInfos");
|
|
129
|
+
|
|
130
|
+
document.querySelector('body').classList.remove("better-errors-javascript-not-loaded");
|
|
131
|
+
document.querySelector('body').classList.add("better-errors-javascript-loaded");
|
|
132
|
+
|
|
133
|
+
var noJSNotices = document.querySelectorAll('.no-javascript-notice');
|
|
134
|
+
for(var i = 0; i < noJSNotices.length; i++) {
|
|
135
|
+
noJSNotices[i].remove();
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function apiCall(method, opts, cb) {
|
|
139
|
+
var req = new XMLHttpRequest();
|
|
140
|
+
req.open("POST", "//" + window.location.host + <%== uri_prefix.gsub("<", "<").inspect %> + "/__better_errors/" + OID + "/" + method, true);
|
|
141
|
+
req.setRequestHeader("Content-Type", "application/json");
|
|
142
|
+
opts.csrfToken = csrfToken;
|
|
143
|
+
req.send(JSON.stringify(opts));
|
|
144
|
+
req.onreadystatechange = function() {
|
|
145
|
+
if(req.readyState == 4) {
|
|
146
|
+
var res = JSON.parse(req.responseText);
|
|
147
|
+
cb(res);
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function escapeHTML(html) {
|
|
153
|
+
return html.replace(/&/, "&").replace(/</g, "<");
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function hasConsoleBeenUsedPreviously() {
|
|
157
|
+
return !!document.cookie.split('; ').find(function(cookie) {
|
|
158
|
+
return cookie.startsWith('BetterErrors-has-used-console=');
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
var consoleHasBeenUsed = hasConsoleBeenUsedPreviously();
|
|
163
|
+
|
|
164
|
+
function consoleWasJustUsed() {
|
|
165
|
+
if (consoleHasBeenUsed) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
hideConsoleHint();
|
|
170
|
+
consoleHasBeenUsed = true;
|
|
171
|
+
document.cookie = "BetterErrors-has-used-console=true;path=/;max-age=31536000;samesite"
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function hideConsoleHint() {
|
|
175
|
+
document.querySelector('body').className += " console-has-been-used";
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
function REPL(index) {
|
|
179
|
+
this.index = index;
|
|
180
|
+
|
|
181
|
+
var previousCommands = JSON.parse(localStorage.getItem("better_errors_previous_commands"));
|
|
182
|
+
if(previousCommands === null) {
|
|
183
|
+
localStorage.setItem("better_errors_previous_commands", JSON.stringify([]));
|
|
184
|
+
previousCommands = [];
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
this.previousCommandOffset = previousCommands.length;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
REPL.all = [];
|
|
191
|
+
|
|
192
|
+
REPL.prototype.install = function(containerElement) {
|
|
193
|
+
this.container = containerElement;
|
|
194
|
+
|
|
195
|
+
this.promptElement = this.container.querySelector(".command-line .prompt");
|
|
196
|
+
this.inputElement = this.container.querySelector("input");
|
|
197
|
+
this.outputElement = this.container.querySelector("pre");
|
|
198
|
+
|
|
199
|
+
if (consoleHasBeenUsed) {
|
|
200
|
+
hideConsoleHint();
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
var self = this;
|
|
204
|
+
this.inputElement.onkeydown = function(ev) {
|
|
205
|
+
self.onKeyDown(ev);
|
|
206
|
+
consoleWasJustUsed();
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
this.setPrompt(">>");
|
|
210
|
+
|
|
211
|
+
REPL.all[this.index] = this;
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
REPL.prototype.focus = function() {
|
|
215
|
+
this.inputElement.focus();
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
REPL.prototype.setPrompt = function(prompt) {
|
|
219
|
+
this._prompt = prompt;
|
|
220
|
+
this.promptElement.innerHTML = escapeHTML(prompt);
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
REPL.prototype.getInput = function() {
|
|
224
|
+
return this.inputElement.value;
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
REPL.prototype.setInput = function(text) {
|
|
228
|
+
this.inputElement.value = text;
|
|
229
|
+
|
|
230
|
+
if(this.inputElement.setSelectionRange) {
|
|
231
|
+
// set cursor to end of input
|
|
232
|
+
this.inputElement.setSelectionRange(text.length, text.length);
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
REPL.prototype.writeRawOutput = function(output) {
|
|
237
|
+
this.outputElement.innerHTML += output;
|
|
238
|
+
this.outputElement.scrollTop = this.outputElement.scrollHeight;
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
REPL.prototype.writeOutput = function(output) {
|
|
242
|
+
this.writeRawOutput(escapeHTML(output));
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
REPL.prototype.sendInput = function(line) {
|
|
246
|
+
var self = this;
|
|
247
|
+
apiCall("eval", { "index": this.index, source: line }, function(response) {
|
|
248
|
+
if(response.error) {
|
|
249
|
+
self.writeOutput(response.error + "\n");
|
|
250
|
+
}
|
|
251
|
+
self.writeOutput(self._prompt + " ");
|
|
252
|
+
self.writeRawOutput("<span class='syntax-highlighted'>" + response.highlighted_input + "</span>\n");
|
|
253
|
+
self.writeOutput(response.result);
|
|
254
|
+
self.setPrompt(response.prompt);
|
|
255
|
+
self.setInput(response.prefilled_input);
|
|
256
|
+
});
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
REPL.prototype.onEnterKey = function() {
|
|
260
|
+
var text = this.getInput();
|
|
261
|
+
if(text != "" && text !== undefined) {
|
|
262
|
+
var previousCommands = JSON.parse(localStorage.getItem("better_errors_previous_commands"));
|
|
263
|
+
this.previousCommandOffset = previousCommands.push(text);
|
|
264
|
+
if(previousCommands.length > 100) {
|
|
265
|
+
previousCommands.splice(0, 1);
|
|
266
|
+
this.previousCommandOffset -= 1;
|
|
267
|
+
}
|
|
268
|
+
localStorage.setItem("better_errors_previous_commands", JSON.stringify(previousCommands));
|
|
269
|
+
}
|
|
270
|
+
this.setInput("");
|
|
271
|
+
this.sendInput(text);
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
REPL.prototype.onNavigateHistory = function(direction) {
|
|
275
|
+
this.previousCommandOffset += direction;
|
|
276
|
+
var previousCommands = JSON.parse(localStorage.getItem("better_errors_previous_commands"));
|
|
277
|
+
|
|
278
|
+
if(this.previousCommandOffset < 0) {
|
|
279
|
+
this.previousCommandOffset = -1;
|
|
280
|
+
this.setInput("");
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
if(this.previousCommandOffset >= previousCommands.length) {
|
|
285
|
+
this.previousCommandOffset = previousCommands.length;
|
|
286
|
+
this.setInput("");
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
this.setInput(previousCommands[this.previousCommandOffset]);
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
REPL.prototype.onKeyDown = function(ev) {
|
|
294
|
+
if(ev.keyCode == 13) {
|
|
295
|
+
this.onEnterKey();
|
|
296
|
+
} else if(ev.keyCode == 38 || (ev.ctrlKey && ev.keyCode == 80)) {
|
|
297
|
+
// the user pressed the up arrow or Ctrl-P
|
|
298
|
+
this.onNavigateHistory(-1);
|
|
299
|
+
ev.preventDefault();
|
|
300
|
+
return false;
|
|
301
|
+
} else if(ev.keyCode == 40 || (ev.ctrlKey && ev.keyCode == 78)) {
|
|
302
|
+
// the user pressed the down arrow or Ctrl-N
|
|
303
|
+
this.onNavigateHistory(1);
|
|
304
|
+
ev.preventDefault();
|
|
305
|
+
return false;
|
|
306
|
+
}
|
|
307
|
+
};
|
|
308
|
+
|
|
309
|
+
function switchTo(el) {
|
|
310
|
+
var currentFrameInfo = document.querySelectorAll('.frame_info.current');
|
|
311
|
+
for(var i = 0; i < currentFrameInfo.length; i++) {
|
|
312
|
+
currentFrameInfo[i].className = "frame_info";
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
el.className = "frame_info current";
|
|
316
|
+
|
|
317
|
+
var replInput = el.querySelector('.be-console input');
|
|
318
|
+
if (replInput) replInput.focus();
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
function selectFrameInfo(index) {
|
|
322
|
+
var el = document.querySelector(".frame_info[data-frame-idx='" + index + "']")
|
|
323
|
+
if (!el) {
|
|
324
|
+
el = document.createElement("div");
|
|
325
|
+
el.className = "frame_info";
|
|
326
|
+
el.setAttribute('data-frame-idx', index);
|
|
327
|
+
frameInfos.appendChild(el);
|
|
328
|
+
}
|
|
329
|
+
if(el) {
|
|
330
|
+
if (el.loaded) {
|
|
331
|
+
return switchTo(el);
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
apiCall("variables", { "index": index }, function(response) {
|
|
335
|
+
el.loaded = true;
|
|
336
|
+
if(response.error) {
|
|
337
|
+
el.innerHTML = "<h2 class='error'>" + escapeHTML(response.error) + "</h2>";
|
|
338
|
+
if(response.explanation) {
|
|
339
|
+
el.innerHTML += "<p class='explanation'>" + escapeHTML(response.explanation) + "</p>";
|
|
340
|
+
}
|
|
341
|
+
el.innerHTML += "<p><a target='_new' href='https://github.com/BetterErrors/better_errors'>More about Better Errors</a></p>";
|
|
342
|
+
} else {
|
|
343
|
+
el.innerHTML = response.html;
|
|
344
|
+
|
|
345
|
+
var repl = el.querySelector(".be-repl .be-console");
|
|
346
|
+
if(repl) {
|
|
347
|
+
new REPL(index).install(repl);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
switchTo(el);
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
for(var i = 0; i < allFrames.length; i++) {
|
|
356
|
+
(function(i, el) {
|
|
357
|
+
var el = allFrames[i];
|
|
358
|
+
el.onclick = function() {
|
|
359
|
+
if(previousFrame) {
|
|
360
|
+
previousFrame.className = "";
|
|
361
|
+
}
|
|
362
|
+
el.className = "selected";
|
|
363
|
+
previousFrame = el;
|
|
364
|
+
|
|
365
|
+
selectFrameInfo(el.attributes["data-index"].value);
|
|
366
|
+
};
|
|
367
|
+
})(i);
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
// Click the first application frame
|
|
371
|
+
(
|
|
372
|
+
document.querySelector(".frames li.application") ||
|
|
373
|
+
document.querySelector(".frames li")
|
|
374
|
+
).onclick();
|
|
375
|
+
|
|
376
|
+
// This is the second query performed for frames; maybe the 'allFrames' list
|
|
377
|
+
// currently used and this list can be better used to avoid the repetition:
|
|
378
|
+
var applicationFramesCount = document.querySelectorAll(
|
|
379
|
+
"ul.frames li[data-context=application]"
|
|
380
|
+
).length;
|
|
381
|
+
|
|
382
|
+
var applicationFramesButtonIsInstalled = false;
|
|
383
|
+
var applicationFramesButton = document.getElementById("application_frames");
|
|
384
|
+
var allFramesButton = document.getElementById("all_frames");
|
|
385
|
+
|
|
386
|
+
// The application frames button only needs to be bound if
|
|
387
|
+
// there are actually any application frames to look at.
|
|
388
|
+
var installApplicationFramesButton = function() {
|
|
389
|
+
applicationFramesButton.onclick = function() {
|
|
390
|
+
allFramesButton.className = "";
|
|
391
|
+
applicationFramesButton.className = "selected";
|
|
392
|
+
for(var i = 0; i < allFrames.length; i++) {
|
|
393
|
+
if(allFrames[i].attributes["data-context"].value == "application") {
|
|
394
|
+
allFrames[i].style.display = "block";
|
|
395
|
+
} else {
|
|
396
|
+
allFrames[i].style.display = "none";
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
return false;
|
|
400
|
+
};
|
|
401
|
+
|
|
402
|
+
applicationFramesButtonIsInstalled = true;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
allFramesButton.onclick = function() {
|
|
406
|
+
if(applicationFramesButtonIsInstalled) {
|
|
407
|
+
applicationFramesButton.className = "";
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
allFramesButton.className = "selected";
|
|
411
|
+
for(var i = 0; i < allFrames.length; i++) {
|
|
412
|
+
allFrames[i].style.display = "block";
|
|
413
|
+
}
|
|
414
|
+
return false;
|
|
415
|
+
};
|
|
416
|
+
|
|
417
|
+
// If there are no application frames, select the 'All Frames'
|
|
418
|
+
// tab by default.
|
|
419
|
+
if(applicationFramesCount > 0) {
|
|
420
|
+
installApplicationFramesButton();
|
|
421
|
+
applicationFramesButton.onclick();
|
|
422
|
+
} else {
|
|
423
|
+
applicationFramesButton.className = "disabled";
|
|
424
|
+
applicationFramesButton.title = "No application frames available";
|
|
425
|
+
allFramesButton.onclick();
|
|
426
|
+
}
|
|
427
|
+
})();
|
|
428
|
+
</script>
|
|
429
|
+
</html>
|
|
430
|
+
|
|
431
|
+
<!-- generated by Better Errors in <%= Time.now.to_f - @start_time %> seconds -->
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<%== text_heading("=", "%s at %s" % [exception_type, request_path]) %>
|
|
2
|
+
|
|
3
|
+
<%== exception_message %>
|
|
4
|
+
|
|
5
|
+
> To access an interactive console with this error, point your browser to: /__better_errors
|
|
6
|
+
|
|
7
|
+
<% if backtrace_frames.any? -%>
|
|
8
|
+
|
|
9
|
+
<%== text_heading("-", "%s, line %i" % [first_frame.pretty_path, first_frame.line]) %>
|
|
10
|
+
|
|
11
|
+
``` ruby
|
|
12
|
+
<%== ErrorPage.text_formatted_code_block(first_frame) %>```
|
|
13
|
+
|
|
14
|
+
App backtrace
|
|
15
|
+
-------------
|
|
16
|
+
|
|
17
|
+
<%== application_frames.map { |s| " - #{s}" }.join("\n") %>
|
|
18
|
+
|
|
19
|
+
Full backtrace
|
|
20
|
+
--------------
|
|
21
|
+
|
|
22
|
+
<%== backtrace_frames.map { |s| " - #{s}" }.join("\n") %>
|
|
23
|
+
|
|
24
|
+
<% end %>
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
<header class="trace_info clearfix">
|
|
2
|
+
<div class="title">
|
|
3
|
+
<h2 class="name"><%= frame.name %></h2>
|
|
4
|
+
<div class="location">
|
|
5
|
+
<span class="filename">
|
|
6
|
+
<a
|
|
7
|
+
href="<%= editor_url %>"
|
|
8
|
+
<%= ENV.key?('BETTER_ERRORS_INSIDE_FRAME') ? "target=_blank" : '' %>
|
|
9
|
+
><%= frame.pretty_path %></a>
|
|
10
|
+
</span>
|
|
11
|
+
</div>
|
|
12
|
+
</div>
|
|
13
|
+
<div class="code_block clearfix">
|
|
14
|
+
<%== ErrorPage.html_formatted_code_block frame %>
|
|
15
|
+
</div>
|
|
16
|
+
|
|
17
|
+
<% if BetterErrors.binding_of_caller_available? && frame.frame_binding %>
|
|
18
|
+
<div class="be-repl">
|
|
19
|
+
<div class="be-console">
|
|
20
|
+
<pre></pre>
|
|
21
|
+
<div class="command-line"><span class='prompt'>>></span> <input tabindex="1"/></div>
|
|
22
|
+
</div>
|
|
23
|
+
</div>
|
|
24
|
+
<% end %>
|
|
25
|
+
</header>
|
|
26
|
+
|
|
27
|
+
<% if BetterErrors.binding_of_caller_available? && frame.frame_binding %>
|
|
28
|
+
<div class="hint live-console-hint">
|
|
29
|
+
This is a live shell. Type in here.
|
|
30
|
+
</div>
|
|
31
|
+
|
|
32
|
+
<div class="variable_info"></div>
|
|
33
|
+
<% end %>
|
|
34
|
+
|
|
35
|
+
<% unless BetterErrors.binding_of_caller_available? %>
|
|
36
|
+
<div class="hint">
|
|
37
|
+
<strong>Tip:</strong> add <code>gem "binding_of_caller"</code> to your Gemfile to enable the REPL and local/instance variable inspection.
|
|
38
|
+
</div>
|
|
39
|
+
<% end %>
|
|
40
|
+
|
|
41
|
+
<%# TODO: move this outside of the frame info. It's not part of the frame. %>
|
|
42
|
+
<div class="sub">
|
|
43
|
+
<h3>Request info</h3>
|
|
44
|
+
<div class='inset variables'>
|
|
45
|
+
<table class="var_table">
|
|
46
|
+
<% if rails_params %>
|
|
47
|
+
<tr><td class="name">Request parameters</td><td><pre><%== ErrorPage.inspect_value rails_params %></pre></td></tr>
|
|
48
|
+
<% end %>
|
|
49
|
+
<% if rack_session %>
|
|
50
|
+
<tr><td class="name">Rack session</td><td><pre><%== ErrorPage.inspect_value rack_session %></pre></td></tr>
|
|
51
|
+
<% end %>
|
|
52
|
+
</table>
|
|
53
|
+
</div>
|
|
54
|
+
</div>
|
|
55
|
+
|
|
56
|
+
<% if BetterErrors.binding_of_caller_available? && frame.frame_binding %>
|
|
57
|
+
<div class="sub">
|
|
58
|
+
<h3>Local Variables</h3>
|
|
59
|
+
<div class='inset variables'>
|
|
60
|
+
<table class="var_table">
|
|
61
|
+
<% frame.local_variables.each do |name, value| %>
|
|
62
|
+
<tr><td class="name"><%= name %></td><td><pre><%== ErrorPage.inspect_value value %></pre></td></tr>
|
|
63
|
+
<% end %>
|
|
64
|
+
</table>
|
|
65
|
+
</div>
|
|
66
|
+
</div>
|
|
67
|
+
|
|
68
|
+
<div class="sub">
|
|
69
|
+
<h3>Instance Variables</h3>
|
|
70
|
+
<div class="inset variables">
|
|
71
|
+
<table class="var_table">
|
|
72
|
+
<% frame.instance_variables.each do |name, value| %>
|
|
73
|
+
<tr><td class="name"><%= name %></td><td><pre><%== ErrorPage.inspect_value value %></pre></td></tr>
|
|
74
|
+
<% end %>
|
|
75
|
+
</table>
|
|
76
|
+
</div>
|
|
77
|
+
</div>
|
|
78
|
+
<% end %>
|
|
79
|
+
|
|
80
|
+
<% if start_time %>
|
|
81
|
+
<!-- variable_info took <%= Time.now.to_f - start_time %> seconds -->
|
|
82
|
+
<% end %>
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
require "pp"
|
|
2
|
+
require "erubi"
|
|
3
|
+
require "uri"
|
|
4
|
+
|
|
5
|
+
require "better_errors/version"
|
|
6
|
+
require "better_errors/code_formatter"
|
|
7
|
+
require "better_errors/inspectable_value"
|
|
8
|
+
require "better_errors/error_page"
|
|
9
|
+
require "better_errors/middleware"
|
|
10
|
+
require "better_errors/raised_exception"
|
|
11
|
+
require "better_errors/repl"
|
|
12
|
+
require "better_errors/stack_frame"
|
|
13
|
+
require "better_errors/editor"
|
|
14
|
+
|
|
15
|
+
module BetterErrors
|
|
16
|
+
class << self
|
|
17
|
+
# The path to the root of the application. Better Errors uses this property
|
|
18
|
+
# to determine if a file in a backtrace should be considered an application
|
|
19
|
+
# frame. If you are using Better Errors with Rails, you do not need to set
|
|
20
|
+
# this attribute manually.
|
|
21
|
+
#
|
|
22
|
+
# @return [String]
|
|
23
|
+
attr_accessor :application_root
|
|
24
|
+
|
|
25
|
+
# The logger to use when logging exception details and backtraces. If you
|
|
26
|
+
# are using Better Errors with Rails, you do not need to set this attribute
|
|
27
|
+
# manually. If this attribute is `nil`, nothing will be logged.
|
|
28
|
+
#
|
|
29
|
+
# @return [Logger, nil]
|
|
30
|
+
attr_accessor :logger
|
|
31
|
+
|
|
32
|
+
# @private
|
|
33
|
+
attr_accessor :binding_of_caller_available
|
|
34
|
+
|
|
35
|
+
# @private
|
|
36
|
+
alias_method :binding_of_caller_available?, :binding_of_caller_available
|
|
37
|
+
|
|
38
|
+
# The ignored instance variables.
|
|
39
|
+
# @return [Array]
|
|
40
|
+
attr_accessor :ignored_instance_variables
|
|
41
|
+
|
|
42
|
+
# The maximum variable payload size. If variable.inspect exceeds this,
|
|
43
|
+
# the variable won't be returned.
|
|
44
|
+
# @return int
|
|
45
|
+
attr_accessor :maximum_variable_inspect_size
|
|
46
|
+
|
|
47
|
+
# List of classes that are excluded from inspection.
|
|
48
|
+
# @return [Array]
|
|
49
|
+
attr_accessor :ignored_classes
|
|
50
|
+
end
|
|
51
|
+
@ignored_instance_variables = []
|
|
52
|
+
@maximum_variable_inspect_size = 100_000
|
|
53
|
+
@ignored_classes = ['ActionDispatch::Request', 'ActionDispatch::Response']
|
|
54
|
+
|
|
55
|
+
# Returns an object which responds to #url, which when called with
|
|
56
|
+
# a filename and line number argument,
|
|
57
|
+
# returns a URL to open the filename and line in the selected editor.
|
|
58
|
+
#
|
|
59
|
+
# Generates TextMate URLs by default.
|
|
60
|
+
#
|
|
61
|
+
# BetterErrors.editor.url("/some/file", 123)
|
|
62
|
+
# # => txmt://open?url=file:///some/file&line=123
|
|
63
|
+
#
|
|
64
|
+
# @return [Proc]
|
|
65
|
+
def self.editor
|
|
66
|
+
@editor ||= default_editor
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# Configures how Better Errors generates open-in-editor URLs.
|
|
70
|
+
#
|
|
71
|
+
# @overload BetterErrors.editor=(sym)
|
|
72
|
+
# Uses one of the preset editor configurations. Valid symbols are:
|
|
73
|
+
#
|
|
74
|
+
# * `:textmate`, `:txmt`, `:tm`
|
|
75
|
+
# * `:sublime`, `:subl`, `:st`
|
|
76
|
+
# * `:macvim`
|
|
77
|
+
# * `:atom`
|
|
78
|
+
#
|
|
79
|
+
# @param [Symbol] sym
|
|
80
|
+
#
|
|
81
|
+
# @overload BetterErrors.editor=(str)
|
|
82
|
+
# Uses `str` as the format string for generating open-in-editor URLs.
|
|
83
|
+
#
|
|
84
|
+
# Use `%{file}` and `%{line}` as placeholders for the actual values.
|
|
85
|
+
#
|
|
86
|
+
# @example
|
|
87
|
+
# BetterErrors.editor = "my-editor://open?url=%{file}&line=%{line}"
|
|
88
|
+
#
|
|
89
|
+
# @param [String] str
|
|
90
|
+
#
|
|
91
|
+
# @overload BetterErrors.editor=(proc)
|
|
92
|
+
# Uses `proc` to generate open-in-editor URLs. The proc will be called
|
|
93
|
+
# with `file` and `line` parameters when a URL needs to be generated.
|
|
94
|
+
#
|
|
95
|
+
# Your proc should take care to escape `file` appropriately with
|
|
96
|
+
# `URI.encode_www_form_component` (please note that `URI.escape` is **not**
|
|
97
|
+
# a suitable substitute.)
|
|
98
|
+
#
|
|
99
|
+
# @example
|
|
100
|
+
# BetterErrors.editor = proc { |file, line|
|
|
101
|
+
# "my-editor://open?url=#{URI.encode_www_form_component file}&line=#{line}"
|
|
102
|
+
# }
|
|
103
|
+
#
|
|
104
|
+
# @param [Proc] proc
|
|
105
|
+
#
|
|
106
|
+
def self.editor=(editor)
|
|
107
|
+
if editor.is_a? Symbol
|
|
108
|
+
@editor = Editor.editor_from_symbol(editor)
|
|
109
|
+
raise(ArgumentError, "Symbol #{editor} is not a symbol in the list of supported errors.") unless editor
|
|
110
|
+
elsif editor.is_a? String
|
|
111
|
+
@editor = Editor.for_formatting_string(editor)
|
|
112
|
+
elsif editor.respond_to? :call
|
|
113
|
+
@editor = Editor.for_proc(editor)
|
|
114
|
+
else
|
|
115
|
+
raise ArgumentError, "Expected editor to be a valid editor key, a format string or a callable."
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
# Enables experimental Pry support in the inline REPL
|
|
120
|
+
#
|
|
121
|
+
# If you encounter problems while using Pry, *please* file a bug report at
|
|
122
|
+
# https://github.com/BetterErrors/better_errors/issues
|
|
123
|
+
def self.use_pry!
|
|
124
|
+
REPL::PROVIDERS.unshift const: :Pry, impl: "better_errors/repl/pry"
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
# Automatically sniffs a default editor preset based on the EDITOR
|
|
128
|
+
# environment variable.
|
|
129
|
+
#
|
|
130
|
+
# @return [Symbol]
|
|
131
|
+
def self.default_editor
|
|
132
|
+
Editor.default_editor
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
begin
|
|
137
|
+
require "binding_of_caller"
|
|
138
|
+
require "better_errors/exception_extension"
|
|
139
|
+
BetterErrors.binding_of_caller_available = true
|
|
140
|
+
rescue LoadError
|
|
141
|
+
BetterErrors.binding_of_caller_available = false
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
require "better_errors/rails" if defined? Rails::Railtie
|