refactor(Compiler): improve the error message on component load error

by adding the fetched url.

relates to #1460
This commit is contained in:
Victor Berchet
2015-06-01 11:07:14 +02:00
parent a504fa835e
commit c60091b949
4 changed files with 15 additions and 9 deletions

View File

@ -36,8 +36,9 @@ export class DomCompiler extends RenderCompiler {
var tplPromise = this._templateLoader.load(template);
return PromiseWrapper.then(
tplPromise, (el) => this._compileTemplate(template, el, ProtoViewDto.COMPONENT_VIEW_TYPE),
(_) => {
throw new BaseException(`Failed to load the template "${template.componentId}"`);
(e) => {
throw new BaseException(
`Failed to load the template for "${template.componentId}" : ${e}`);
});
}

View File

@ -32,10 +32,14 @@ export class TemplateLoader {
var promise = StringMapWrapper.get(this._htmlCache, url);
if (isBlank(promise)) {
promise = this._xhr.get(url).then(function(html) {
// TODO(vicb): change error when TS gets fixed
// https://github.com/angular/angular/issues/2280
// throw new BaseException(`Failed to fetch url "${url}"`);
promise = PromiseWrapper.then(this._xhr.get(url), html => {
var template = DOM.createTemplate(html);
return template;
});
}, _ => PromiseWrapper.reject(new BaseException(`Failed to fetch url "${url}"`), null));
StringMapWrapper.set(this._htmlCache, url, promise);
}