diff --git a/lib/layer.js b/lib/layer.js index 6a4408f..198c929 100644 --- a/lib/layer.js +++ b/lib/layer.js @@ -83,12 +83,18 @@ function Layer (path, options, fn) { } } - return pathRegexp.match((opts.strict ? _path : loosen(_path)), { - sensitive: opts.sensitive, - end: opts.end, - trailing: !opts.strict, - decode: decodeParam - }) + try { + return pathRegexp.match((opts.strict ? _path : loosen(_path)), { + sensitive: opts.sensitive, + end: opts.end, + trailing: !opts.strict, + decode: decodeParam + }); + } + catch (err) { + console.error(err); + throw new Error(`The path route '${_path}' could not be parsed. Check the above error message for details.`); + } } this.matchers = Array.isArray(path) ? path.map(matcher) : [matcher(path)] }