diff options
author | isaacs <i@izs.me> | 2011-02-20 02:36:42 +0300 |
---|---|---|
committer | isaacs <i@izs.me> | 2011-02-20 02:36:42 +0300 |
commit | 8518923b6527ba82f23d063e94d736760c34973b (patch) | |
tree | b34cfc99c477d8d723e1ae5e751eb58095231190 | |
parent | 3e90c99827acd65fddbc5ecca5b18fd3e1091aab (diff) |
Pass the buck on package.json parse errors.
-rw-r--r-- | lib/utils/error-handler.js | 10 | ||||
-rw-r--r-- | lib/utils/read-json.js | 3 | ||||
-rw-r--r-- | npm.js | 1 |
3 files changed, 12 insertions, 2 deletions
diff --git a/lib/utils/error-handler.js b/lib/utils/error-handler.js index 0bcdd156a..615008114 100644 --- a/lib/utils/error-handler.js +++ b/lib/utils/error-handler.js @@ -62,9 +62,17 @@ function errorHandler (er) { ," "+er.script ,"You can get their info via:" ," npm owner ls "+er.pkgname - ,"There may be additional logging output above." + ,"There is likely additional logging output above." ].join("\n")) break + case npm.EJSONPARSE: + log.error(["","Failed to parse package.json data." + ,"Note that package.json must be actual JSON, not" + ,"just a JavaScript object." + ,"","This changed in npm 0.3.0, and is not a bug in npm." + ,"Tell the package author to fix their package.json file." + ,""].join("\n"), "JSON.parse") + break case npm.E404: log.error(["","Looks like '"+er.pkgid+"' is not in the npm registry." ,"You should bug the author to publish it." diff --git a/lib/utils/read-json.js b/lib/utils/read-json.js index 62bff7f8c..653a591db 100644 --- a/lib/utils/read-json.js +++ b/lib/utils/read-json.js @@ -71,7 +71,8 @@ function processJsonString (opts, cb) { return function (er, jsonString) { json = JSON.parse(jsonString) } catch (ex) { var e = new Error( - "Failed to parse json\n"+ex.message+"\n"+jsonString) + "Failed to parse json\n"+ex.message) + e.errno = npm.EJSONPARSE if (cb) return cb(e) throw e } @@ -26,6 +26,7 @@ npm.commands = {} npm.ELIFECYCLE = {} npm.E404 = {} npm.EPUBLISHCONFLICT = {} +npm.EJSONPARSE = {} try { |