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

feat(core): add source to `StaticInjectorError` message #20817

Closed
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
5 participants
@ocombe
Contributor

ocombe commented Dec 6, 2017

PR Type

What kind of change does this PR introduce?

[x] Feature

What is the current behavior?

We need more info on StaticInjectorError to help with debugging

Issue Number: #19302, also Fixes #20172

What is the new behavior?

We add the source component (or module) that tried to inject the missing provider, and we also add the source from the injector which triggered the error

Notes:

  • I couldn't get the name of the module containing the component with the failing injector, only the name of the main module (that created the injector).
  • I added a property on tokens named __source, we could use a different property name (I wasn't inspired), but I'm not sure if it's ok to add a property name like that.
  • I'm not sure if adding "Platform: core" for the root injector is really useful, I could remove it

Does this PR introduce a breaking change?

[x] No

Other information

I already did a PR with that change but we had to revert because of issues in g3, but I don't know what were the issues, and I haven't changed the code since then.

@mary-poppins

This comment has been minimized.

Show comment
Hide comment
@mary-poppins

mary-poppins commented Dec 6, 2017

@jasonaden

This comment has been minimized.

Show comment
Hide comment
@jasonaden

jasonaden Dec 6, 2017

Contributor

Was rolled back in g3. Determine cause before merging.

Contributor

jasonaden commented Dec 6, 2017

Was rolled back in g3. Determine cause before merging.

@@ -25,7 +25,7 @@ export function moduleProvideDef(
// lowered the expression and then stopped evaluating it,
// i.e. also didn't unwrap it.
value = resolveForwardRef(value);
const depDefs = splitDepsDsl(deps);

This comment has been minimized.

@mhevery

mhevery Dec 6, 2017

Member

The issue is that token can be null

@mhevery

mhevery Dec 6, 2017

Member

The issue is that token can be null

This comment has been minimized.

@mhevery

mhevery Dec 6, 2017

Member

You should use stringify from core/src/util here as stringify(token)

@mhevery

mhevery Dec 6, 2017

Member

You should use stringify from core/src/util here as stringify(token)

@mary-poppins

This comment has been minimized.

Show comment
Hide comment
@mary-poppins

mary-poppins commented Dec 11, 2017

@jasonaden jasonaden closed this in b7738e1 Dec 13, 2017

@ocombe ocombe deleted the ocombe:feat/static-injector branch Jan 19, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment