[Pkg-javascript-commits] [uglifyjs] 85/491: document 3.x minify() does not throw errors (#1975)

Jonas Smedegaard dr at jones.dk
Wed Feb 14 19:51:24 UTC 2018


This is an automated email from the git hooks/post-receive script.

js pushed a commit to annotated tag debian/3.3.10-1
in repository uglifyjs.

commit 5bf8d7e9490155ed6fabea5f1140a87a1e9b596e
Author: kzc <kzc at users.noreply.github.com>
Date:   Fri May 19 22:49:35 2017 -0400

    document 3.x minify() does not throw errors (#1975)
---
 README.md | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md
index 579390c..f73bd27 100644
--- a/README.md
+++ b/README.md
@@ -307,7 +307,7 @@ Example:
 ```javascript
 var result = UglifyJS.minify("var b = function() {};");
 console.log(result.code);  // minified output
-console.log(result.error); // runtime error
+console.log(result.error); // runtime error, if present
 ```
 
 You can also compress multiple files:
@@ -335,6 +335,12 @@ var result = UglifyJS.minify({"foo.js" : "if (0) else console.log(1);"});
 console.log(JSON.stringify(result.error));
 // {"message":"Unexpected token: keyword (else)","filename":"foo.js","line":1,"col":7,"pos":7}
 ```
+Note: unlike `uglify-js at 2.x`, the `3.x` API does not throw errors. To 
+achieve a similar effect one could do the following:
+```javascript
+var result = UglifyJS.minify("if (0) else console.log(1);");
+if (result.error) throw result.error;
+```
 
 ## Minify options
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/uglifyjs.git



More information about the Pkg-javascript-commits mailing list