From 3d91b93c616c00b7292f2e11a8c68f053f5bd3d8 Mon Sep 17 00:00:00 2001 From: Rebecca Turner Date: Thu, 15 Mar 2018 23:17:32 -0700 Subject: [PATCH] fix(errors): Unknown auth errors use default code (#1) If we can't identify the auth problem we should pass it through with default settings. (This was an error in the npm-profile implementation.) --- errors.js | 1 - test/errors.js | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/errors.js b/errors.js index cbaca0fa..217f46f9 100644 --- a/errors.js +++ b/errors.js @@ -52,7 +52,6 @@ class HttpErrorAuthUnknown extends HttpErrorBase { constructor (method, res, body, spec) { super(method, res, body, spec) this.message = 'Unable to authenticate, need: ' + res.headers.get('www-authenticate') - this.code = 'EAUTHUNOWN' Error.captureStackTrace(this, HttpErrorAuthUnknown) } } diff --git a/test/errors.js b/test/errors.js index 593a5500..0dcdd423 100644 --- a/test/errors.js +++ b/test/errors.js @@ -117,7 +117,7 @@ test('Unexpected www-authenticate error', t => { () => { throw new Error('Should not have succeeded!') }, err => { t.match(err.body.error, /Pat-a-cake/ig, 'error body explains it') - t.equal(err.code, 'EAUTHUNOWN', 'got a special pokemon') + t.equal(err.code, 'E401', 'Unknown auth errors are generic 401s') } ) })