feat(ivy): improve stacktrace for R3Injector errors (#28207)

Improve the stacktrace for `R3Injector` errors by adding the source component (or module) that tried to inject the missing provider, as well as the name of the injector which triggered the error (`R3Injector`).

e.g.:
```
R3InjectorError(SomeModule)[car -> SportsCar]:
    NullInjectorError: No provider for SportsCar!
```

FW-807 #resolve
FW-875 #resolve

PR Close #28207
This commit is contained in:
Olivier Combe
2019-01-17 18:48:39 +01:00
committed by Matias Niemelä
parent 7219639ff3
commit 728fe69625
10 changed files with 230 additions and 77 deletions

View File

@ -16,7 +16,6 @@ import {InternalNgModuleRef, NgModuleFactory as viewEngine_NgModuleFactory, NgMo
import {NgModuleDef} from '../metadata/ng_module';
import {assertDefined} from '../util/assert';
import {stringify} from '../util/stringify';
import {ComponentFactoryResolver} from './component_ref';
import {getNgModuleDef} from './definition';
@ -52,7 +51,8 @@ export class NgModuleRef<T> extends viewEngine_NgModuleRef<T> implements Interna
},
COMPONENT_FACTORY_RESOLVER
];
this._r3Injector = createInjector(ngModuleType, _parent, additionalProviders) as R3Injector;
this._r3Injector = createInjector(
ngModuleType, _parent, additionalProviders, stringify(ngModuleType)) as R3Injector;
this.instance = this.get(ngModuleType);
}