Skip to content

Commit

Permalink
Make missing parameter error more descriptive (#283)
Browse files Browse the repository at this point in the history
Make missing parameter error more descriptive
  • Loading branch information
rwjblue authored Jun 27, 2019
2 parents 5a897b8 + 1596570 commit 83500dd
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lib/router/transition-intent/named-transition-intent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ export default class NamedTransitionIntent<T extends Route> extends TransitionIn

// Soak up all the provided string/numbers
let numNames = names.length;
let missingParams = [];
while (numNames--) {
// Only use old params if the names match with the new handler
let oldParams =
Expand All @@ -222,13 +223,16 @@ export default class NamedTransitionIntent<T extends Route> extends TransitionIn
if (oldParams.hasOwnProperty(paramName)) {
params[paramName] = oldParams[paramName];
} else {
throw new Error(
"You didn't provide enough string/numeric parameters to satisfy all of the dynamic segments for route " +
name
);
missingParams.push(paramName);
}
}
}
if (missingParams.length > 0) {
throw new Error(
`You didn't provide enough string/numeric parameters to satisfy all of the dynamic segments for route ${name}.` +
` Missing params: ${missingParams}`
);
}

return new UnresolvedRouteInfoByParam(this.router, name, names, params);
}
Expand Down

0 comments on commit 83500dd

Please sign in to comment.