Skip to content

Commit

Permalink
fix(github): try/catch getCommitStatus check
Browse files Browse the repository at this point in the history
  • Loading branch information
rarkins committed Apr 25, 2019
1 parent 4da4c13 commit 34fbb7c
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion lib/platform/github/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,19 @@ async function getBranchStatus(branchName, requiredStatusChecks) {
const commitStatusUrl = `repos/${
config.repository
}/commits/${branchName}/status`;
const commitStatus = (await get(commitStatusUrl)).body;
let commitStatus;
try {
commitStatus = (await get(commitStatusUrl)).body;
} catch (err) /* istanbul ignore next */ {
if (err.statusCode === 404) {
logger.info(
'Received 404 when checking branch status, assuming that branch has been deleted'
);
throw new Error('repository-changed');
}
logger.info('Unknown error when checking branch status');
throw err;
}
logger.debug(
{ state: commitStatus.state, statuses: commitStatus.statuses },
'branch status check result'
Expand Down

0 comments on commit 34fbb7c

Please sign in to comment.