Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make missing parameter error more descriptive #283

Merged
merged 1 commit into from
Jun 27, 2019
Merged
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
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