From: Edward Casbon Date: Mon, 11 Aug 2014 11:40:01 +0000 (+0100) Subject: Add filename to the JS_Parse_Error exception. X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=ae07714927f44790e40628cde4fa57bc2c4cb076;p=UglifyJS.git Add filename to the JS_Parse_Error exception. It would be nice to have access to the filename of the file that includes the code that causes a JavaScript error. This is especially handy if uglifying multiple files at once. Only a small change is needed for this to happen as it's already available in the function that throws the error. --- diff --git a/lib/parse.js b/lib/parse.js index 78c1dd41..0e269ab7 100644 --- a/lib/parse.js +++ b/lib/parse.js @@ -187,8 +187,9 @@ function parse_js_number(num) { } }; -function JS_Parse_Error(message, line, col, pos) { +function JS_Parse_Error(message, filename, line, col, pos) { this.message = message; + this.filename = filename; this.line = line; this.col = col; this.pos = pos; @@ -200,7 +201,7 @@ JS_Parse_Error.prototype.toString = function() { }; function js_error(message, filename, line, col, pos) { - throw new JS_Parse_Error(message, line, col, pos); + throw new JS_Parse_Error(message, filename, line, col, pos); }; function is_token(token, type, val) {