diff --git a/modules/angular2/src/render/dom/compiler/view_loader.ts b/modules/angular2/src/render/dom/compiler/view_loader.ts index aa140268ae..ca1429ada5 100644 --- a/modules/angular2/src/render/dom/compiler/view_loader.ts +++ b/modules/angular2/src/render/dom/compiler/view_loader.ts @@ -36,7 +36,7 @@ export class ViewLoader { load(viewDef: ViewDefinition): Promise { var r = wtfStartTimeRange('ViewLoader#load()', stringify(viewDef.componentId)); let tplAndStyles: List| Promise| string> = - [this._loadHtml(viewDef.template, viewDef.templateAbsUrl)]; + [this._loadHtml(viewDef.template, viewDef.templateAbsUrl, viewDef.componentId)]; if (isPresent(viewDef.styles)) { viewDef.styles.forEach((cssText: string) => { let textOrPromise = this._resolveAndInlineCssText(cssText, viewDef.templateAbsUrl); @@ -83,7 +83,8 @@ export class ViewLoader { } // Load the html and inline any style tags - private _loadHtml(template: string, templateAbsUrl: string): Promise { + private _loadHtml(template: string, templateAbsUrl: string, + componentId: string): Promise { let html; // Load the HTML @@ -92,7 +93,8 @@ export class ViewLoader { } else if (isPresent(templateAbsUrl)) { html = this._loadText(templateAbsUrl); } else { - throw new BaseException('View should have either the templateUrl or template property set'); + throw new BaseException( + `View should have either the templateUrl or template property set but none was found for the '${componentId}' component`); } return html.then(html => { diff --git a/modules/angular2/test/render/dom/compiler/view_loader_spec.ts b/modules/angular2/test/render/dom/compiler/view_loader_spec.ts index 87a3f124e2..eb8ded30c0 100644 --- a/modules/angular2/test/render/dom/compiler/view_loader_spec.ts +++ b/modules/angular2/test/render/dom/compiler/view_loader_spec.ts @@ -83,8 +83,10 @@ export function main() { })); it('should throw when no template is defined', () => { - expect(() => loader.load(new ViewDefinition({template: null, templateAbsUrl: null}))) - .toThrowError('View should have either the templateUrl or template property set'); + expect(() => loader.load(new ViewDefinition( + {componentId: 'TestComponent', template: null, templateAbsUrl: null}))) + .toThrowError( + 'View should have either the templateUrl or template property set but none was found for the \'TestComponent\' component'); }); it('should return a rejected Promise when XHR loading fails',