fix: throw useful error on missing platform module.

This commit is contained in:
Misko Hevery
2016-07-29 14:45:05 -07:00
parent 8c8754e573
commit 73f02c7861
4 changed files with 69 additions and 47 deletions

View File

@ -313,7 +313,10 @@ export class PlatformRef_ extends PlatformRef {
const ngZoneInjector =
ReflectiveInjector.resolveAndCreate([{provide: NgZone, useValue: ngZone}], this.injector);
const moduleRef = moduleFactory.create(ngZoneInjector);
const exceptionHandler: ExceptionHandler = moduleRef.injector.get(ExceptionHandler);
const exceptionHandler: ExceptionHandler = moduleRef.injector.get(ExceptionHandler, null);
if (!exceptionHandler) {
throw new Error('No ExceptionHandler. Is platform module (BrowserModule) included?');
}
ObservableWrapper.subscribe(ngZone.onError, (error: NgZoneError) => {
exceptionHandler.call(error.error, error.stackTrace);
});