From a89d23331802cabb690ac817a5a7c93144a4f9c9 Mon Sep 17 00:00:00 2001 From: Mihai Bazon Date: Mon, 2 Sep 2013 09:55:34 +0300 Subject: [PATCH] Better reporting of parse errors --- bin/uglifyjs | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/bin/uglifyjs b/bin/uglifyjs index 7a4f6224..90b71a20 100755 --- a/bin/uglifyjs +++ b/bin/uglifyjs @@ -257,11 +257,21 @@ async.eachLimit(files, 1, function (file, cb) { }); } else { - TOPLEVEL = UglifyJS.parse(code, { - filename : file, - toplevel : TOPLEVEL, - expression : ARGS.expr, - }); + try { + TOPLEVEL = UglifyJS.parse(code, { + filename : file, + toplevel : TOPLEVEL, + expression : ARGS.expr, + }); + } catch(ex) { + if (ex instanceof UglifyJS.JS_Parse_Error) { + sys.error("Parse error at " + file + ":" + ex.line + "," + ex.col); + sys.error(ex.message); + sys.error(ex.stack); + process.exit(1); + } + throw ex; + } }; }); cb(); -- 2.34.1