Файл: README.html
Строк: 197
<?php
<!DOCTYPE html>
<html lang="en">
<head>
<title>Error Kitty</title>
<link href="http://fonts.googleapis.com/css?family=Open+Sans:400,700" rel="stylesheet" type="text/css">
<link href="https://highlightjs.org/static/styles/github.css" rel="stylesheet" type="text/css">
<style>
html,
body {
font-family: "Open Sans", sans-serif;
}
img {
max-width: 100%;
}
pre {
background-color: #f9f9f9;
padding: 20px;
}
#container {
margin: 0 auto;
margin-bottom: 40px;
width: 650px;
}
</style>
</head>
<body>
<div id="container">
<h1>Error Kitty</h1>
<p><strong>Error Kitty</strong> pounces on your exceptions. It adds an interactive stack trace to your connect and express applications to make debugging a breeze. Not only that but a code frame is added to your console stack traces including syntax highlighting to make your console more beautiful and easier to read.</p>
<p>See <a href="http://error-kitty.sebmck.com/">error-kitty.sebmck.com</a> for a live demo.</p>
<h2>Screenshots</h2>
<h3>Web</h3>
<p><img src="screenshot-web.png" alt="Web Screenshot"></p>
<h3>Console</h3>
<p><img src="screenshot-console.png" alt="Console Screenshot"></p>
<h2>Installation</h2>
<ol>
<li>Extract your downloaded zip.</li>
<li>Move the <code>error-kitty</code> folder into <code>node_modules</code> within your application.</li>
<li><a href="#usage">Add it to your project!</a></li>
</ol>
<h2 id="usage">Usage</h2>
<h3>Stacks</h3>
<p>Simply add</p>
<pre><code class="language-javascript"><span class="hljs-built_in">require</span>(<span class="hljs-string">"error-kitty"</span>);</code></pre>
<p>to the top of your code. It's that easy!</p>
<h3>Middleware</h3>
<p>In order to catch all errors thrown by your application we need to add some
middleware. See
<a href="http://expressjs.com/guide/using-middleware.html">express - middleware</a> for an
explanation on middleware and it's function.</p>
<p>You must insert the following code:</p>
<pre><code class="language-javascript"><span class="hljs-keyword">if</span> (process.env.NODE_ENV !== <span class="hljs-string">"production"</span>) {
app.use(<span class="hljs-built_in">require</span>(<span class="hljs-string">"error-kitty"</span>).middleware());
}</code></pre>
<p><strong>right before</strong> <code>app.listen(PORT);</code>.</p>
<h4>Walkthrough</h4>
<p>For example, say you have the following code:</p>
<pre><code class="language-javascript"><span class="hljs-keyword">var</span> express = <span class="hljs-built_in">require</span>(<span class="hljs-string">"express"</span>);
<span class="hljs-keyword">var</span> app = express();
app.use(express.static(<span class="hljs-string">"static"</span>));
app.get(<span class="hljs-string">"/"</span>, <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-params">()</span> </span>{
<span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Error</span>(<span class="hljs-string">"foobar"</span>);
});
app.listen(<span class="hljs-number">9999</span>);</code></pre>
<p>You would make the following modifications:</p>
<pre><code class="language-javascript"><span class="hljs-keyword">var</span> errorKitty = <span class="hljs-built_in">require</span>(<span class="hljs-string">"error-kitty"</span>);
<span class="hljs-keyword">var</span> express = <span class="hljs-built_in">require</span>(<span class="hljs-string">"express"</span>);
<span class="hljs-keyword">var</span> app = express();
app.use(express.static(<span class="hljs-string">"static"</span>));
app.get(<span class="hljs-string">"/"</span>, <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-params">()</span> </span>{
<span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Error</span>(<span class="hljs-string">"foobar"</span>);
});
<span class="hljs-keyword">if</span> (process.env.NODE_ENV !== <span class="hljs-string">"production"</span>) {
app.use(errorKitty.middleware());
}
app.listen(<span class="hljs-number">9999</span>);</code></pre>
</div>
</body>
</html>
?>