Skip to content
Myr

Moved try/catch block

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

authored by visionmedia · committed by visionmedia · parent 2b3fadf · Browse files · 1 file+12 added−17 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+12 added−17 removed

  • other:+12 added−17 removed

1 file+12 added−17 removed

modified:lib/express.core.js+12 added-17 removed
55 unmodified lines
56 57 hook : function(name, args) {58 if (this.hookCallbacks[name])59 for (i = 0, len = this.hookCallbacks[name].length; i < len; ++i)60 if (typeof this.hookCallbacks[name][i] == 'function')60 this.hookCallbacks[name][i].apply(this, this.argsArray(arguments, 1))61 this.hookCallbacks[name][i].apply(this, this.argsArray(arguments, 1))62 },63 64 /**65 * Add middlware _callback_ for hook _name_.
15 unmodified lines
81 */82 83 start : function(port) {84 this.server.listen(port || 3000, function(request, response){84 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', Express.request, Express.response)93 }94 catch (e) {95 Express.fail(e)96 }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 try { Express.response.body = Express.callRouteFor(request) }91 catch (e) { Express.fail(e) }92 Express.prepareCookie()93 Express.hook('response', Express.request, Express.response)94 response.sendHeader(Express.response.status, Express.hashToArray(Express.response.headers))95 response.sendBody(Express.response.body || '')96 response.finish()97 })98 },99 100 fail : function(e) {101 this.header('Content-Type', 'text/html')105 this.response.status = 500106 this.response.body = e.name + ': ' + e.message102 this.response.body = this.respond(e.name + ': ' + e.message, 500)103 },104 105 server : {106
450 unmodified lines
557})558559get(/articles\/(\d+)/, function(){560 header('Content-Type', 'text/html')565 throw new Error('Oh no')561 'article id ' + captures[1]562})563564get('articles/:name', function(){
7 unmodified lines