refactor(Compiler): improve the error message on component load error
by adding the fetched url. relates to #1460
This commit is contained in:
@ -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}`);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user