From 1c99673d50f6eb87618cbcbc5b59034cdb2d84f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kat=20March=C3=A1n?= Date: Wed, 19 Dec 2018 09:31:38 -0800 Subject: [PATCH] audit: report any errors above 400 as potentially not supporting audit Fixes: https://npm.community/t/npm-audit-fails-with-enoaudit-on-500-response/3629 Fixes: https://npm.community/t/npm-audit-error-messaging-update-for-401s/3983 --- lib/audit.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/audit.js b/lib/audit.js index 076ca256b7c72..15ca2d9ed2818 100644 --- a/lib/audit.js +++ b/lib/audit.js @@ -189,8 +189,8 @@ function auditCmd (args, cb) { }).then((auditReport) => { return audit.submitForFullReport(auditReport) }).catch((err) => { - if (err.statusCode === 404 || err.statusCode >= 500) { - const ne = new Error(`Your configured registry (${opts.registry}) does not support audit requests.`) + if (err.statusCode >= 400) { + const ne = new Error(`Your configured registry (${opts.registry}) does not support audit requests, or the audit endpoint is temporarily unavailable.`) ne.code = 'ENOAUDIT' ne.wrapped = err throw ne