Skip to content
Myr

Added NotFoundError

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

authored by visionmedia · committed by visionmedia · parent 1aa275b · Browse files · 1 file+18 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

1 file+18 added−0 removed

  • other:+18 added−0 removed

1 file+18 added−0 removed

modified:lib/express/core.js+18 added
8 unmodified lines
9 init: function(method, path, fn, options){10 this.method = method11 this.originalPath = path12 this.path = pathToRegexp(normalizePath(path))13 print(this.path)14 this.fn = fn15 },16 run: function(){17 return process.compile('with(Express.helpers){ (' + this.fn + ')() }', this.method + '(' + jsonEncode(this.originalPath) + ')')
4 unmodified lines
2223var captures = [],24 params = {}2526ExpressError = Class({27 name: 'ExpressError',28 init: function(message) {29 this.message = message30 },31 toString: function() {32 return this.name + ': ' + this.message33 }34}) 35NotFoundError = ExpressError.extend({36 name: 'NotFoundError',37 init: function(request) {38 this.message = 'failed to find ' + request.method + ' ' + jsonEncode(request.uri.path)39 }40})4142Router = Class({43 route: function(request){44 this.request = request45 return this.matchingRoute().run()
2 unmodified lines
48 matchingRoute: function(){49 for (var i = 0, len = Express.routes.length; i < len; ++i)50 if (this.match(Express.routes[i]))51 return Express.routes[i]52 throw new NotFoundError(this.request)53 },54 55 /**56 * Check if _route_ matches the current request.
187 unmodified lines