diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2017-05-10 04:20:59 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-10 04:20:59 +0800 |
commit | a0f5f862dfe5667471fc99265f6163ca676c3f58 (patch) | |
tree | b0dbe0c51b7b5685f155cfa9f59bc24c2b1e537c /bin/uglifyjs | |
parent | 41996be86f326f667e755cfa953d32befbfa3076 (diff) | |
download | tracifyjs-a0f5f862dfe5667471fc99265f6163ca676c3f58.tar.gz tracifyjs-a0f5f862dfe5667471fc99265f6163ca676c3f58.zip |
gracefully handle non-`Error` being thrown (#1893)
Diffstat (limited to 'bin/uglifyjs')
-rwxr-xr-x | bin/uglifyjs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/bin/uglifyjs b/bin/uglifyjs index d75b0ee1..65b761c6 100755 --- a/bin/uglifyjs +++ b/bin/uglifyjs @@ -193,7 +193,7 @@ function run() { } } } catch (ex) { - fatal(ex.stack); + fatal(ex); } var result = UglifyJS.minify(files, options); if (result.error) { @@ -220,7 +220,7 @@ function run() { console.error("Supported options:"); console.error(ex.defs); } - fatal(ex.stack); + fatal(ex); } else if (program.output == "ast") { console.log(JSON.stringify(result.ast, function(key, value) { if (skip_key(key)) return; @@ -263,7 +263,8 @@ function run() { } function fatal(message) { - console.error(message.replace(/^\S*?Error:/, "ERROR:")); + if (message instanceof Error) message = message.stack.replace(/^\S*?Error:/, "ERROR:") + console.error(message); process.exit(1); } @@ -303,7 +304,7 @@ function read_file(path, default_value) { return fs.readFileSync(path, "utf8"); } catch (ex) { if (ex.code == "ENOENT" && default_value != null) return default_value; - fatal(ex.stack); + fatal(ex); } } |