Skip to content

Commit

Permalink
feat: More descriptive error for SyntaxError
Browse files Browse the repository at this point in the history
  • Loading branch information
paveltiunov committed Jun 26, 2019
1 parent b08333f commit f6d12d3
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ class DataSchemaCompiler {
return Object.assign({}, file, { content });
} catch (e) {
if (e.toString().indexOf('SyntaxError') !== -1) {
errorsReport.error(`Syntax error during '${file.fileName}' parsing: ${e.message}`);
const line = file.content.split('\n')[e.loc.line - 1];
const spaces = Array(e.loc.column).fill(' ').join('');
errorsReport.error(`Syntax error during '${file.fileName}' parsing: ${e.message}:\n${line}\n${spaces}^`);
} else {
errorsReport.error(e);
}
Expand Down

0 comments on commit f6d12d3

Please sign in to comment.