Add error handling.

This commit is contained in:
Paul van Brenk 2015-04-22 14:27:05 -07:00
parent c6a9c8fa89
commit b1472d99f2

View file

@ -802,17 +802,27 @@ module ts {
return this.forwardJSONCall(
"getTSConfigFileInfo('" + fileName + "')",
() => {
var text = sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength());
var json = /\S/.test(text) ? JSON.parse(text) : {};
let text = sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength());
var configFile = parseConfigFile(json, this.host, getDirectoryPath(normalizeSlashes(fileName)));
try {
var json = /\S/.test(text) ? JSON.parse(text) : {};
}
catch (e) {
return {
options: {},
files: [],
errors: realizeDiagnostic(createCompilerDiagnostic(Diagnostics.Unable_to_open_file_0, fileName), '\r\n')
}
}
var realErrors = realizeDiagnostics(configFile.errors, '\r\n');
if (json) {
var configFile = parseConfigFile(json, this.host, getDirectoryPath(normalizeSlashes(fileName)));
}
return {
options: configFile.options,
files: configFile.fileNames,
errors: realErrors
errors: realizeDiagnostics(configFile.errors, '\r\n')
};
});
}