diff options
author | isaacs <i@izs.me> | 2011-10-03 04:13:21 +0400 |
---|---|---|
committer | isaacs <i@izs.me> | 2011-10-03 04:13:21 +0400 |
commit | 7ea7f2d6564d21c5a1703bbbc3bd33435b103153 (patch) | |
tree | ef7c9d3948df3acee2e863ebcd2271a0bbe1214c /lib | |
parent | f7b6671b605a7201332fea16fb2c4b4ba2f7f38d (diff) |
Set the er.code for npm-specific errors, and s/EENGINE/ENOTSUP/
Diffstat (limited to 'lib')
-rw-r--r-- | lib/install.js | 2 | ||||
-rw-r--r-- | lib/utils/error-handler.js | 15 |
2 files changed, 14 insertions, 3 deletions
diff --git a/lib/install.js b/lib/install.js index 31fcf32af..01eb1a983 100644 --- a/lib/install.js +++ b/lib/install.js @@ -491,7 +491,7 @@ function checkEngine (target, cb) { if (eng.node && !semver.satisfies(nodev, eng.node) || eng.npm && !semver.satisfies(npmv, eng.npm)) { var er = new Error("Unsupported") - er.errno = npm.EENGINE + er.errno = npm.ENOTSUP er.required = eng er.pkgid = target._id return cb(er) diff --git a/lib/utils/error-handler.js b/lib/utils/error-handler.js index 4dc183da7..d8edc76d3 100644 --- a/lib/utils/error-handler.js +++ b/lib/utils/error-handler.js @@ -56,6 +56,7 @@ function errorHandler (er) { } switch (er.errno) { + case "ECONNREFUSED": case constants.ECONNREFUSED: log.error(er) log.error(["If you are using Cygwin, please set up your /etc/resolv.conf" @@ -67,6 +68,8 @@ function errorHandler (er) { ].join("\n")) break + case "EACCES": + case "EPERM": case constants.EACCES: case constants.EPERM: log.error(er) @@ -83,6 +86,7 @@ function errorHandler (er) { break case npm.ELIFECYCLE: + er.code = "ELIFECYCLE" log.error(er.message) log.error(["","Failed at the "+er.pkgid+" "+er.stage+" script." ,"This is most likely a problem with the "+er.pkgname+" package," @@ -96,6 +100,7 @@ function errorHandler (er) { break case npm.EJSONPARSE: + er.code = "EJSONPARSE" log.error(er.message) log.error("File: "+er.file) log.error(["Failed to parse package.json data." @@ -106,6 +111,7 @@ function errorHandler (er) { break case npm.E404: + er.code = "E404" if (er.pkgid && er.pkgid !== "-") { var msg = ["'"+er.pkgid+"' is not in the npm registry." ,"You could maybe bug the author to publish it"] @@ -122,6 +128,7 @@ function errorHandler (er) { break case npm.EPUBLISHCONFLICT: + er.code = "EPUBLISHCONFLICT" log.error(["Cannot publish over existing version." ,"Bump the 'version' field, set the --force flag, or" ," npm unpublish '"+er.pkgid+"'" @@ -130,6 +137,7 @@ function errorHandler (er) { break case npm.EISGIT: + er.code = "EISGIT" log.error([er.message ," "+er.path ,"Refusing to remove it. Update manually," @@ -138,6 +146,7 @@ function errorHandler (er) { break case npm.ECYCLE: + er.code = "ECYCLE" log.error([er.message ,"While installing: "+er.pkgid ,"Found a pathological dependency case that npm cannot solve." @@ -145,7 +154,8 @@ function errorHandler (er) { ].join("\n")) break - case npm.EENGINE: + case npm.ENOTSUP: + er.code = "ENOTSUP" log.error([er.message ,"Not compatible with your version of node/npm: "+er.pkgid ,"Required: "+JSON.stringify(er.required) @@ -155,6 +165,7 @@ function errorHandler (er) { ].join("\n")) break + case "EEXIST": case constants.EEXIST: log.error([er.message ,"File exists: "+er.path @@ -184,7 +195,7 @@ function errorHandler (er) { if (er.type) log.error(er.type, "type") if (er.arguments) log.error(er.arguments, "arguments") if (er.code) log.error(er.code, "code") - if (er.errno) log.error(er.errno, "errno") + if (er.errno && typeof er.errno !== "object") log.error(er.errno, "errno") exit(typeof er.errno === "number" ? er.errno : 1) } |