Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions lib/layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’d prefer to merge the message you’re suggesting with the error message, rather than logging the error to the console and then throwing a new one

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)]
}
Expand Down