4e14ccc74d
Instiki now runs on the Rails 2.3.0 Candidate Release. Among other improvements, this means that it now automagically selects between WEBrick and Mongrel. Just run ./instiki --daemon
260 lines
13 KiB
HTML
260 lines
13 KiB
HTML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!DOCTYPE html
|
|
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
|
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
|
<head>
|
|
<title>Class: Rack::ShowExceptions</title>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
|
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
|
<script type="text/javascript">
|
|
// <![CDATA[
|
|
|
|
function popupCode( url ) {
|
|
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
|
}
|
|
|
|
function toggleCode( id ) {
|
|
if ( document.getElementById )
|
|
elem = document.getElementById( id );
|
|
else if ( document.all )
|
|
elem = eval( "document.all." + id );
|
|
else
|
|
return false;
|
|
|
|
elemStyle = elem.style;
|
|
|
|
if ( elemStyle.display != "block" ) {
|
|
elemStyle.display = "block"
|
|
} else {
|
|
elemStyle.display = "none"
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
// Make codeblocks hidden by default
|
|
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
|
|
|
// ]]>
|
|
</script>
|
|
|
|
</head>
|
|
<body>
|
|
|
|
|
|
|
|
<div id="classHeader">
|
|
<table class="header-table">
|
|
<tr class="top-aligned-row">
|
|
<td><strong>Class</strong></td>
|
|
<td class="class-name-in-header">Rack::ShowExceptions</td>
|
|
</tr>
|
|
<tr class="top-aligned-row">
|
|
<td><strong>In:</strong></td>
|
|
<td>
|
|
<a href="../../files/lib/rack/showexceptions_rb.html">
|
|
lib/rack/showexceptions.rb
|
|
</a>
|
|
<br />
|
|
</td>
|
|
</tr>
|
|
|
|
<tr class="top-aligned-row">
|
|
<td><strong>Parent:</strong></td>
|
|
<td>
|
|
Object
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
<!-- banner header -->
|
|
|
|
<div id="bodyContent">
|
|
|
|
|
|
|
|
<div id="contextContent">
|
|
|
|
<div id="description">
|
|
<p>
|
|
<a href="ShowExceptions.html">Rack::ShowExceptions</a> catches all
|
|
exceptions raised from the app it wraps. It shows a useful backtrace with
|
|
the sourcefile and clickable context, the whole <a
|
|
href="../Rack.html">Rack</a> environment and the request data.
|
|
</p>
|
|
<p>
|
|
Be careful when you use this on public-facing sites as it could reveal
|
|
information helpful to attackers.
|
|
</p>
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
<div id="method-list">
|
|
<h3 class="section-bar">Methods</h3>
|
|
|
|
<div class="name-list">
|
|
<a href="#M000086">call</a>
|
|
<a href="#M000085">new</a>
|
|
<a href="#M000087">pretty</a>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
<!-- if includes -->
|
|
|
|
<div id="section">
|
|
|
|
|
|
<div id="constants-list">
|
|
<h3 class="section-bar">Constants</h3>
|
|
|
|
<div class="name-list">
|
|
<table summary="Constants">
|
|
<tr class="top-aligned-row context-row">
|
|
<td class="context-item-name">CONTEXT</td>
|
|
<td>=</td>
|
|
<td class="context-item-value">7</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!-- if method_list -->
|
|
<div id="methods">
|
|
<h3 class="section-bar">Public Class methods</h3>
|
|
|
|
<div id="method-M000085" class="method-detail">
|
|
<a name="M000085"></a>
|
|
|
|
<div class="method-heading">
|
|
<a href="#M000085" class="method-signature">
|
|
<span class="method-name">new</span><span class="method-args">(app)</span>
|
|
</a>
|
|
</div>
|
|
|
|
<div class="method-description">
|
|
<p><a class="source-toggle" href="#"
|
|
onclick="toggleCode('M000085-source');return false;">[Source]</a></p>
|
|
<div class="method-source-code" id="M000085-source">
|
|
<pre>
|
|
<span class="ruby-comment cmt"># File lib/rack/showexceptions.rb, line 17</span>
|
|
17: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">app</span>)
|
|
18: <span class="ruby-ivar">@app</span> = <span class="ruby-identifier">app</span>
|
|
19: <span class="ruby-ivar">@template</span> = <span class="ruby-constant">ERB</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">TEMPLATE</span>)
|
|
20: <span class="ruby-keyword kw">end</span>
|
|
</pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<h3 class="section-bar">Public Instance methods</h3>
|
|
|
|
<div id="method-M000086" class="method-detail">
|
|
<a name="M000086"></a>
|
|
|
|
<div class="method-heading">
|
|
<a href="#M000086" class="method-signature">
|
|
<span class="method-name">call</span><span class="method-args">(env)</span>
|
|
</a>
|
|
</div>
|
|
|
|
<div class="method-description">
|
|
<p><a class="source-toggle" href="#"
|
|
onclick="toggleCode('M000086-source');return false;">[Source]</a></p>
|
|
<div class="method-source-code" id="M000086-source">
|
|
<pre>
|
|
<span class="ruby-comment cmt"># File lib/rack/showexceptions.rb, line 22</span>
|
|
22: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">call</span>(<span class="ruby-identifier">env</span>)
|
|
23: <span class="ruby-ivar">@app</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">env</span>)
|
|
24: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">StandardError</span>, <span class="ruby-constant">LoadError</span>, <span class="ruby-constant">SyntaxError</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">e</span>
|
|
25: <span class="ruby-identifier">backtrace</span> = <span class="ruby-identifier">pretty</span>(<span class="ruby-identifier">env</span>, <span class="ruby-identifier">e</span>)
|
|
26: [<span class="ruby-value">500</span>,
|
|
27: {<span class="ruby-value str">"Content-Type"</span> =<span class="ruby-operator">></span> <span class="ruby-value str">"text/html"</span>,
|
|
28: <span class="ruby-value str">"Content-Length"</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">backtrace</span>.<span class="ruby-identifier">join</span>.<span class="ruby-identifier">size</span>.<span class="ruby-identifier">to_s</span>},
|
|
29: <span class="ruby-identifier">backtrace</span>]
|
|
30: <span class="ruby-keyword kw">end</span>
|
|
</pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="method-M000087" class="method-detail">
|
|
<a name="M000087"></a>
|
|
|
|
<div class="method-heading">
|
|
<a href="#M000087" class="method-signature">
|
|
<span class="method-name">pretty</span><span class="method-args">(env, exception)</span>
|
|
</a>
|
|
</div>
|
|
|
|
<div class="method-description">
|
|
<p><a class="source-toggle" href="#"
|
|
onclick="toggleCode('M000087-source');return false;">[Source]</a></p>
|
|
<div class="method-source-code" id="M000087-source">
|
|
<pre>
|
|
<span class="ruby-comment cmt"># File lib/rack/showexceptions.rb, line 32</span>
|
|
32: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">pretty</span>(<span class="ruby-identifier">env</span>, <span class="ruby-identifier">exception</span>)
|
|
33: <span class="ruby-identifier">req</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Request</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">env</span>)
|
|
34: <span class="ruby-identifier">path</span> = (<span class="ruby-identifier">req</span>.<span class="ruby-identifier">script_name</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">req</span>.<span class="ruby-identifier">path_info</span>).<span class="ruby-identifier">squeeze</span>(<span class="ruby-value str">"/"</span>)
|
|
35:
|
|
36: <span class="ruby-identifier">frames</span> = <span class="ruby-identifier">exception</span>.<span class="ruby-identifier">backtrace</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">line</span><span class="ruby-operator">|</span>
|
|
37: <span class="ruby-identifier">frame</span> = <span class="ruby-constant">OpenStruct</span>.<span class="ruby-identifier">new</span>
|
|
38: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">line</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/(.*?):(\d+)(:in `(.*)')?/</span>
|
|
39: <span class="ruby-identifier">frame</span>.<span class="ruby-identifier">filename</span> = <span class="ruby-identifier">$1</span>
|
|
40: <span class="ruby-identifier">frame</span>.<span class="ruby-identifier">lineno</span> = <span class="ruby-identifier">$2</span>.<span class="ruby-identifier">to_i</span>
|
|
41: <span class="ruby-identifier">frame</span>.<span class="ruby-identifier">function</span> = <span class="ruby-identifier">$4</span>
|
|
42:
|
|
43: <span class="ruby-keyword kw">begin</span>
|
|
44: <span class="ruby-identifier">lineno</span> = <span class="ruby-identifier">frame</span>.<span class="ruby-identifier">lineno</span><span class="ruby-operator">-</span><span class="ruby-value">1</span>
|
|
45: <span class="ruby-identifier">lines</span> = <span class="ruby-operator">::</span><span class="ruby-constant">File</span>.<span class="ruby-identifier">readlines</span>(<span class="ruby-identifier">frame</span>.<span class="ruby-identifier">filename</span>)
|
|
46: <span class="ruby-identifier">frame</span>.<span class="ruby-identifier">pre_context_lineno</span> = [<span class="ruby-identifier">lineno</span><span class="ruby-operator">-</span><span class="ruby-constant">CONTEXT</span>, <span class="ruby-value">0</span>].<span class="ruby-identifier">max</span>
|
|
47: <span class="ruby-identifier">frame</span>.<span class="ruby-identifier">pre_context</span> = <span class="ruby-identifier">lines</span>[<span class="ruby-identifier">frame</span>.<span class="ruby-identifier">pre_context_lineno</span><span class="ruby-operator">...</span><span class="ruby-identifier">lineno</span>]
|
|
48: <span class="ruby-identifier">frame</span>.<span class="ruby-identifier">context_line</span> = <span class="ruby-identifier">lines</span>[<span class="ruby-identifier">lineno</span>].<span class="ruby-identifier">chomp</span>
|
|
49: <span class="ruby-identifier">frame</span>.<span class="ruby-identifier">post_context_lineno</span> = [<span class="ruby-identifier">lineno</span><span class="ruby-operator">+</span><span class="ruby-constant">CONTEXT</span>, <span class="ruby-identifier">lines</span>.<span class="ruby-identifier">size</span>].<span class="ruby-identifier">min</span>
|
|
50: <span class="ruby-identifier">frame</span>.<span class="ruby-identifier">post_context</span> = <span class="ruby-identifier">lines</span>[<span class="ruby-identifier">lineno</span><span class="ruby-operator">+</span><span class="ruby-value">1</span><span class="ruby-operator">..</span><span class="ruby-identifier">frame</span>.<span class="ruby-identifier">post_context_lineno</span>]
|
|
51: <span class="ruby-keyword kw">rescue</span>
|
|
52: <span class="ruby-keyword kw">end</span>
|
|
53:
|
|
54: <span class="ruby-identifier">frame</span>
|
|
55: <span class="ruby-keyword kw">else</span>
|
|
56: <span class="ruby-keyword kw">nil</span>
|
|
57: <span class="ruby-keyword kw">end</span>
|
|
58: }.<span class="ruby-identifier">compact</span>
|
|
59:
|
|
60: <span class="ruby-identifier">env</span>[<span class="ruby-value str">"rack.errors"</span>].<span class="ruby-identifier">puts</span> <span class="ruby-node">"#{exception.class}: #{exception.message}"</span>
|
|
61: <span class="ruby-identifier">env</span>[<span class="ruby-value str">"rack.errors"</span>].<span class="ruby-identifier">puts</span> <span class="ruby-identifier">exception</span>.<span class="ruby-identifier">backtrace</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">l</span><span class="ruby-operator">|</span> <span class="ruby-value str">"\t"</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">l</span> }
|
|
62: <span class="ruby-identifier">env</span>[<span class="ruby-value str">"rack.errors"</span>].<span class="ruby-identifier">flush</span>
|
|
63:
|
|
64: [<span class="ruby-ivar">@template</span>.<span class="ruby-identifier">result</span>(<span class="ruby-identifier">binding</span>)]
|
|
65: <span class="ruby-keyword kw">end</span>
|
|
</pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div id="validator-badges">
|
|
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
|
</div>
|
|
|
|
</body>
|
|
</html> |