ui: Improves the 'you must provide ... to `generate`' error from href-to (#9514)

This originally comes form the ember-href-to helper and is one of those
errors that when I see it I think ... hmmm

This gives a little bit more of a clue as to what is wrong by logging
the route name you asked for plus the params you passed to it so you:

1. Have more help finding the href-to that is problematic in the
template/component
2. Can see all the parameters you passed (including a potential null
parameter for the thing you are missing)
This commit is contained in:
John Cowen 2021-01-19 15:25:37 +00:00 committed by GitHub
parent ee368e9a00
commit 41a4a9f4fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 1 deletions

View File

@ -42,7 +42,14 @@ export default class HrefToHelper extends Helper {
@service('router') router;
compute(params, hash) {
return hrefTo(this, this.router, params, hash);
let href;
try {
href = hrefTo(this, this.router, params, hash);
} catch (e) {
e.message = `${e.message} For "${params[0]}:${JSON.stringify(params.slice(1))}"`;
throw e;
}
return href;
}
@observes('router.currentURL')