diff --git a/index.js b/index.js index efe11c7..cdf734b 100644 --- a/index.js +++ b/index.js @@ -486,7 +486,7 @@ class GithubScm extends Scm { return repo.data.permissions; } catch (err) { // Suspended user - if (err.code === 404 && err.message.match(/suspend/i)) { + if (err.message.match(/suspend/i)) { winston.info( `User's account suspended for ${scmInfo.owner}/${scmInfo.repo}, ` + 'it will be removed from pipeline admins.'); diff --git a/test/index.test.js b/test/index.test.js index 07ad84a..0ca380d 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -399,10 +399,9 @@ describe('index', function () { }); }); - it('catches and discards Github errors when it has a 404 error code', () => { + it('catches and discards Github errors when it has a suspended user error message', () => { const err = new Error('Sorry. Your account was suspended.'); - err.code = 404; githubMock.repos.get.yieldsAsync(err); return scm.getPermissions(config) @@ -430,7 +429,7 @@ describe('index', function () { ); }) .catch(() => { - assert(false, 'Error should be handled if error code is 404'); + assert(false, 'Error should be handled if error message has "suspend" string'); }); }); });