Started show exceptions support
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by visionmedia · committed by visionmedia · parent 4ea0e85 · Browse files · 4 files·+46 added−3 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
4 files+46 added−3 removed
- other:+46 added−3 removed
Provenance
- Commit
e728d3c- Tree
c0eefaa- Author
visionmedia <tj@vision-media.ca>- Committer
visionmedia <tj@vision-media.ca>- Parent
4ea0e85
4 files changed+46 added−3 removed
modified:examples/app.js+4 added
29 unmodified lines30313233343536373829 unmodified lines contentType('json') return JSON.encode(messages)})
get('/error', function(){ throw new Error('oh noes!')})
run()No newline at end of fileNo newline at end of filemodified:lib/express/core.js+7 added-2 removed
251 unmodified lines252 header('content-type') == 'application/x-www-form-urlencoded' ?253 parseParams(request.body) :254 {}255 trigger('request')256+ try {256- if (typeof (body = Express.router.route(request)) == 'string')257- halt(200, body)257+ if (typeof (body = Express.router.route(request)) == 'string')258+ halt(200, body)259+ }260+ catch (e) {261+ halt(500, require('express/show-exceptions').render(e))262+ }263 },264 265 /**266 * Respond immediately with optional _body_.32 unmodified linesmodified:lib/express/plugins.js+1 added-1 removed
4 unmodified lines5678994 unmodified linesprocess.mixin(require('express/plugins/redirect'))process.mixin(require('express/plugins/profiler'))process.mixin(require('express/plugins/common-logger'))process.mixin(require('express/plugins/content-length'))process.mixin(require('express/plugins/method-override'))No newline at end of fileprocess.mixin(require('express/plugins/method-override'))added:lib/express/show-exceptions.js+34 added
12345678910111213141516171819202122232425262728293031323334
// Express - Show Exceptions - Copyright TJ Holowaychuk <tj@vision-media.ca> (MIT Licensed)
var style = '<style> \n\ body { \n\ font-family: "Helvetica Neue", "Lucida Grande", "Arial" sans-serif; \n\ font-size: 13px; \n\ -webkit-text-stroke: 1px rgba(255, 255, 255, 0.1); \n\ color: #555; \n\ } \n\ h1, h2 { \n\ color: #343434; \n\ } \n\ </style>'
exports.render = function(e) { contentType('html') var stack = $(e).map(function(val){ return '<li>' + val + '</li>' }) return '<html> \n\ <head> \n\ <title>Express -- Error</title> \n\ ' + style + ' \n\ </head> \n\ <body> \n\ <h1>Express</h1> \n\ <h2>' + e + '</h2> \n\ <ul id="stacktrace"> \n\ ' + stack + ' \n\ </ul> \n\ </body> \n\ </html>'}No newline at end of file