add util.errorWithNode method that returns an error with mapped location properties

This commit is contained in:
Sebastian McKenzie
2014-09-29 12:24:12 +10:00
parent 2e035663e1
commit 886ed42b78

View File

@@ -36,6 +36,13 @@ exports.parse = function (code, opts) {
}
};
exports.errorWithNode = function (node, msg) {
var err = new Error(msg);
err.lineNumber = node.loc.start.line;
err.column = node.loc.start.column;
return err;
};
exports.canCompile = function (filename) {
return path.extname(filename) === ".js";
};