Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRebecca Turner <me@re-becca.org>2017-10-04 07:56:54 +0300
committerRebecca Turner <me@re-becca.org>2017-10-04 11:08:26 +0300
commit8af91528ce6277cd3a8c7ca8c8102671baf10d2f (patch)
tree2ec3e536b2b19c63127759766292a60c8ff3e5fc
parentf644018e6ef1ff7523c6ec60ae55a24e87a9d9ae (diff)
error-message: Add custom error messages
-rw-r--r--lib/utils/error-message.js48
1 files changed, 46 insertions, 2 deletions
diff --git a/lib/utils/error-message.js b/lib/utils/error-message.js
index 49aa9124e..028a18bbb 100644
--- a/lib/utils/error-message.js
+++ b/lib/utils/error-message.js
@@ -66,8 +66,52 @@ function errorMessage (er) {
])
break
- // TODO(isaacs)
- // Add a special case here for E401 and E403 explaining auth issues?
+ case 'EOTP':
+ short.push(['', 'This operation requires a one-time password from your authenticator.'])
+ detail.push([
+ '',
+ [
+ 'You can provide a one-time password by passing --otp=<code> to the command you ran.',
+ 'If you already provided a one-time password then it is likely that you either typoed',
+ 'it, or it timed out. Please try again.'
+ ].join('\n')
+ ])
+ break
+
+ case 'E401':
+ // npm ERR! code E401
+ // npm ERR! Unable to authenticate, need: Basic
+ if (er.headers && er.headers['www-authenticate']) {
+ const auth = er.headers['www-authenticate']
+ if (auth.indexOf('Bearer') !== -1) {
+ short.push(['', 'Unable to authenticate, your authentication token seems to be invalid.'])
+ detail.push([
+ '',
+ [
+ 'To correct this please trying logging in again with:',
+ ' npm login'
+ ].join('\n')
+ ])
+ break
+ } else if (auth.indexOf('Basic') !== -1) {
+ short.push(['', 'Incorrect or missing password.'])
+ detail.push([
+ '',
+ [
+ 'If you were trying to login, change your password, create an',
+ 'authentication token or enable two-factor authentication then',
+ 'that means you likely typed your password in incorectly.',
+ 'Please try again, or recover your password at:',
+ ' https://www.npmjs.com/forgot',
+ '',
+ 'If you were doing some other operation then your saved credentials are',
+ 'probably out of date. To correct this please try logging in again with:',
+ ' npm login'
+ ].join('\n')
+ ])
+ break
+ }
+ }
case 'E404':
// There's no need to have 404 in the message as well.