Skip to content

Commit

Permalink
throw error if route name not found
Browse files Browse the repository at this point in the history
  • Loading branch information
sometimeskind committed Jun 27, 2018
1 parent 4d4b7a8 commit 5e75398
Show file tree
Hide file tree
Showing 3 changed files with 2,273 additions and 2,267 deletions.
8 changes: 7 additions & 1 deletion lib/am-path-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,13 @@ export default function getPathHelpers(routesMap: { [routeName: string]: { path?
.reduce((evaluatedPaths, routeName) => ({ ...evaluatedPaths, [routeName]: getPaths(routeName).map((path) => pathToRegexp(path)) }), {});

function evalPathParams(routeName: string, path: string): ?ParamsType {
return pathCheckers[routeName].reduce((evaulatedParams, checker, index) => {
const pathChecker = pathCheckers[routeName];

if (!Array.isArray(pathChecker)) {
throw new Error(`${routeName} not found in routes`);
}

return pathChecker.reduce((evaulatedParams, checker, index) => {
if (evaulatedParams) {
return evaulatedParams;
}
Expand Down
Loading

0 comments on commit 5e75398

Please sign in to comment.