log filename in parse errors / compressor warnings
This commit is contained in:
14
lib/parse.js
14
lib/parse.js
@@ -254,9 +254,13 @@ JS_Parse_Error.prototype.toString = function() {
|
||||
return this.message + " (line: " + this.line + ", col: " + this.col + ", pos: " + this.pos + ")" + "\n\n" + this.stack;
|
||||
};
|
||||
|
||||
function js_error(message, line, col, pos) {
|
||||
console.log("***", message);
|
||||
console.log("*** LINE:", line, "COL:", col, "POS:", pos);
|
||||
function js_error(message, filename, line, col, pos) {
|
||||
AST_Node.warn("ERROR: {message} [{file}:{line},{col}]", {
|
||||
message: message,
|
||||
file: filename,
|
||||
line: line,
|
||||
col: col
|
||||
});
|
||||
throw new JS_Parse_Error(message, line, col, pos);
|
||||
};
|
||||
|
||||
@@ -270,6 +274,7 @@ function tokenizer($TEXT, filename) {
|
||||
|
||||
var S = {
|
||||
text : $TEXT.replace(/\r\n?|[\n\u2028\u2029]/g, "\n").replace(/^\uFEFF/, ''),
|
||||
filename : filename,
|
||||
pos : 0,
|
||||
tokpos : 0,
|
||||
line : 0,
|
||||
@@ -354,7 +359,7 @@ function tokenizer($TEXT, filename) {
|
||||
};
|
||||
|
||||
function parse_error(err) {
|
||||
js_error(err, S.tokline, S.tokcol, S.tokpos);
|
||||
js_error(err, filename, S.tokline, S.tokcol, S.tokpos);
|
||||
};
|
||||
|
||||
function read_num(prefix) {
|
||||
@@ -718,6 +723,7 @@ function parse($TEXT, options) {
|
||||
function croak(msg, line, col, pos) {
|
||||
var ctx = S.input.context();
|
||||
js_error(msg,
|
||||
ctx.filename,
|
||||
line != null ? line : ctx.tokline,
|
||||
col != null ? col : ctx.tokcol,
|
||||
pos != null ? pos : ctx.tokpos);
|
||||
|
||||
Reference in New Issue
Block a user