Cleaning up 500 page code
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by visionmedia · committed by visionmedia · parent ae904e4 · Browse files · 1 file·+33 added−7 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
1 file+33 added−7 removed
- other:+33 added−7 removed
Provenance
- Commit
78d3d4d- Tree
2cf8f0c- Author
visionmedia <tj@vision-media.ca>- Committer
visionmedia <tj@vision-media.ca>- Parent
ae904e4
1 file changed+33 added−7 removed
modified:lib/express/pages/show-exceptions.js+33 added-7 removed
123456767891011121314159161718192021222317242526272829303132333435363738394041424344452 unmodified lines484950513052533254553456575859606162636465
// Express - Pages - Show Exceptions - Copyright TJ Holowaychuk <tj@vision-media.ca> (MIT Licensed)
var style = require('express/pages/style').style
exports.render = function(request, e) { request.contentType('html')/** * Return list items for exception _e_'s stack. * * @param {object} e * @return {string} * @api private */
function stack(e) { if (e.stack) var stack = $(e.stack.split('\n').slice(1)).map(function(val, i){ return $(e.stack.split('\n').slice(1)).map(function(val, i){ if (!i) return '<li>' + val.replace(/^(.*?):/, '<span class="path">$1</span>:') + '</li>' return '<li>' + val .replace(/\(([^:]+)/, '(<span class="path">$1</span>') .replace(/(:\d+:\d+)/, '<span class="line">$1</span>') + '</li>' }).join('\n') var requestHeaders = $(request.headers).map(function(val, key){}
/** * Return table rows for headers _hash_. * * @param {hash} hash * @return {string} * @api private */
function headers(hash) { return $(hash).map(function(val, key){ return '<tr><td>' + key + ':</td><td>' + val + '</td></tr>' }).join('\n')}
exports.render = function(request, e) { request.contentType('html') return '<html> \n\ <head> \n\ <title>Express -- ' + e + '</title> \n\ ' + style + ' \n\2 unmodified lines <div id="wrapper"> \n\ <h1>Express</h1> \n\ <h2><em>500</em> ' + e + '</h2> \n\ <ul id="stacktrace"> \n\ ' + stack + ' \n\ ' + stack(e) + ' \n\ </ul> \n\ <h3>Request Headers</h3> \n\ <h3>Request</h3> \n\ <table id="request-headers"> \n\ ' + requestHeaders + ' \n\ ' + headers(request.headers) + ' \n\ </table> \n\ <h3>Response</h3> \n\ <table id="response-headers"> \n\ ' + headers(request.response.headers) + '\n\ </table> \n\ </div> \n\ </body> \n\ </html>'}No newline at end of fileNo newline at end of file