MOBILE-2795 compile: Show error on template parsing

main
Pau Ferrer Ocaña 2019-01-11 08:55:33 +01:00
parent 953c5ab0a4
commit 65d048c494
2 changed files with 17 additions and 9 deletions

View File

@ -102,6 +102,10 @@ export class CoreCompileHtmlComponent implements OnChanges, OnDestroy, DoCheck {
this.created.emit(this.componentRef.instance);
}
this.loaded = true;
}).catch((error) => {
this.domUtils.showErrorModal(error);
this.loaded = true;
});
}

View File

@ -170,16 +170,20 @@ export class CoreCompileProvider {
// Now create the module containing the component.
const module = NgModule({imports: imports, declarations: [component]})(class {});
// Compile the module and the component.
return this.compiler.compileModuleAndAllComponentsAsync(module).then((factories) => {
// Search and return the factory of the component we just created.
for (const i in factories.componentFactories) {
const factory = factories.componentFactories[i];
if (factory.componentType == component) {
return factory;
try {
// Compile the module and the component.
return this.compiler.compileModuleAndAllComponentsAsync(module).then((factories) => {
// Search and return the factory of the component we just created.
for (const i in factories.componentFactories) {
const factory = factories.componentFactories[i];
if (factory.componentType == component) {
return factory;
}
}
}
});
});
} catch (ex) {
return Promise.reject({message: 'Template has some errors and cannot be displayed.', debuginfo: ex});
}
}
/**