More error handling docs
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Tj Holowaychuk · committed by Tj Holowaychuk · parent 6b54c1b · Browse files · 3 files·+59 added−0 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
3 files+59 added−0 removed
- other:+59 added−0 removed
Provenance
- Commit
cea401c- Tree
8c084b1- Author
Tj Holowaychuk <tj@vision-media.ca>- Committer
Tj Holowaychuk <tj@vision-media.ca>- Parent
6b54c1b
3 files changed+59 added−0 removed
modified:docs/guide.1+29 added
345 unmodified lines346 .fi347 .348 .IP "" 0349 .350+.P351+Our apps could also utilize the Connect \fIerrorHandler\fR middleware to report on exceptions\. For example if we wish to output exceptions in \"development\" mode to \fIstderr\fR we can use:352+.353+.IP "" 4354+.355+.nf356+357+app\.use(\'/\', connect\.errorHandler({ dumpExceptions: true }));358+.359+.fi360+.361+.IP "" 0362+.363+.P364+Also during development we may want fancy html pages to show exceptions that are passed or thrown, so we can set \fIshowStack\fR to true:365+.366+.IP "" 4367+.368+.nf369+370+app\.use(\'/\', connect\.errorHandler({ showStack: true, dumpExceptions: true }));371+.372+.fi373+.374+.IP "" 0375+.376+.P377+The \fIerrorHandler\fR middleware also responds with \fIjson\fR if \fIAccept: application/json\fR is present, which is useful for developing apps that rely heavily on client\-side JavaScript\.378+.379 .SS "View Rendering"380 View filenames take the form \fINAME\fR\.\fIENGINE\fR, where \fIENGINE\fR is the name of the module that will be required\. For example the view \fIlayout\.ejs\fR will tell the view system to \fIrequire(\'ejs\')\fR, the module being loaded must (currently) export the method \fIexports\.render(str, options)\fR to comply with Express, however with will likely be extensible in the future\.381 .382 .P478 unmodified linesmodified:docs/guide.html+16 added
441 unmodified lines442 });443 });444 </code></pre>445 446+<p>Our apps could also utilize the Connect <em>errorHandler</em> middleware447+to report on exceptions. For example if we wish to output exceptions448+in "development" mode to <em>stderr</em> we can use:</p>449+450+<pre><code>app.use('/', connect.errorHandler({ dumpExceptions: true }));451+</code></pre>452+453+<p>Also during development we may want fancy html pages to show exceptions454+that are passed or thrown, so we can set <em>showStack</em> to true:</p>455+456+<pre><code>app.use('/', connect.errorHandler({ showStack: true, dumpExceptions: true }));457+</code></pre>458+459+<p>The <em>errorHandler</em> middleware also responds with <em>json</em> if <em>Accept: application/json</em>460+is present, which is useful for developing apps that rely heavily on client-side JavaScript.</p>461+462 <h3 id="View-Rendering">View Rendering</h3>463 464 <p>View filenames take the form <em>Express</em>.<em>ENGINE</em>, where <em>ENGINE</em> is the name465 of the module that will be required. For example the view <em>layout.ejs</em> will322 unmodified linesmodified:docs/guide.md+14 added
211 unmodified lines212 } 213 });214 });215 216+Our apps could also utilize the Connect _errorHandler_ middleware217+to report on exceptions. For example if we wish to output exceptions 218+in "development" mode to _stderr_ we can use:219+220+ app.use('/', connect.errorHandler({ dumpExceptions: true }));221+222+Also during development we may want fancy html pages to show exceptions223+that are passed or thrown, so we can set _showStack_ to true:224+225+ app.use('/', connect.errorHandler({ showStack: true, dumpExceptions: true }));226+227+The _errorHandler_ middleware also responds with _json_ if _Accept: application/json_228+is present, which is useful for developing apps that rely heavily on client-side JavaScript.229+230 ### View Rendering231 232 View filenames take the form _NAME_._ENGINE_, where _ENGINE_ is the name233 of the module that will be required. For example the view _layout.ejs_ will283 unmodified lines