fix(compiler): improve error messages in aot compiler (#14333)

Do not print the stack trace when the component is not declared in the module.

PR Close #14333
This commit is contained in:
Bowen Ni 2017-02-06 15:26:30 -08:00 committed by Miško Hevery
parent bb4db2d8f3
commit a696f4aade
1 changed files with 4 additions and 2 deletions

View File

@ -19,6 +19,7 @@ import * as o from '../output/output_ast';
import {CompiledStylesheet, StyleCompiler} from '../style_compiler'; import {CompiledStylesheet, StyleCompiler} from '../style_compiler';
import {SummaryResolver} from '../summary_resolver'; import {SummaryResolver} from '../summary_resolver';
import {TemplateParser} from '../template_parser/template_parser'; import {TemplateParser} from '../template_parser/template_parser';
import {syntaxError} from '../util';
import {ViewCompiler} from '../view_compiler/view_compiler'; import {ViewCompiler} from '../view_compiler/view_compiler';
import {AotCompilerHost} from './compiler_host'; import {AotCompilerHost} from './compiler_host';
@ -290,8 +291,9 @@ export function analyzeAndValidateNgModules(
const result = analyzeNgModules(programStaticSymbols, host, metadataResolver); const result = analyzeNgModules(programStaticSymbols, host, metadataResolver);
if (result.symbolsMissingModule && result.symbolsMissingModule.length) { if (result.symbolsMissingModule && result.symbolsMissingModule.length) {
const messages = result.symbolsMissingModule.map( const messages = result.symbolsMissingModule.map(
s => `Cannot determine the module for class ${s.name} in ${s.filePath}!`); s =>
throw new Error(messages.join('\n')); `Cannot determine the module for class ${s.name} in ${s.filePath}! Add ${s.name} to the NgModule to fix it.`);
throw syntaxError(messages.join('\n'));
} }
return result; return result;
} }