Skip to content
Myr

Added Express.fail()

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by visionmedia · committed by visionmedia · parent 5f11b4a · Browse files · 1 file+21 added−9 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+21 added−9 removed

  • other:+21 added−9 removed

1 file+21 added−9 removed

modified:lib/express.core.js+21 added-9 removed
80 unmodified lines
81 */82 83 start : function(port) {84 this.server.listen(port || 3000, function(request, response){85 try {85 Express.request = request86 request.headers = Express.arrayToHash(request.headers)87 Express.hook('request', request, response)88 request.uri.params = Express.parseNestedParams(request.uri.params)89 request.uri.path = Express.normalizePath(request.uri.path)90 Express.response.body = Express.callRouteFor(request)91 Express.prepareCookie()92 Express.hook('response', request, response)86 Express.request = request87 request.headers = Express.arrayToHash(request.headers)88 Express.hook('request', request, response)89 request.uri.params = Express.parseNestedParams(request.uri.params)90 request.uri.path = Express.normalizePath(request.uri.path)91 Express.response.body = Express.callRouteFor(request)92 Express.prepareCookie()93 Express.hook('response', Express.request, Express.response)94 }95 catch (e) {96 Express.fail(e)97 }98 response.sendHeader(Express.response.status, Express.hashToArray(Express.response.headers))99 response.sendBody(Express.response.body || '')100 response.finish()101 })102 },103 104 fail : function(e) {105 this.header('Content-Type', 'text/html')106 this.response.status = 500107 this.response.body = e.name + ': ' + e.message108 },109 110 server : {111 112 /**113 * Listen to _port_ with _callback_.
407 unmodified lines
521 522})()523524use('response', Express.Logger)525use('response', Express.ShowExceptions)526527get('user/:name/:operation', function(){528 p(request.headers['User-Agent'])529 p(request.headers['Accept'])
18 unmodified lines
548})549550get(/articles\/(\d+)/, function(){551 header('Content-Type', 'text/html')540 p(header('Accept'))552 throw new Error('Oh no')553 'article id ' + captures[1]554})555556get('articles/:name', function(){
7 unmodified lines