Skip to content

Commit

Permalink
Handle 502 edge case.
Browse files Browse the repository at this point in the history
Signed-off-by: Akshay Sharma <akshay.sharma@fresha.com>
  • Loading branch information
akshaysharma096 committed Sep 30, 2024
1 parent 9880754 commit d115d4a
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,18 +94,24 @@ async function getJobStatus(jobName, statusUrl) {
break;
case 502:
if (failureCount > FAILURE_THRESHOLD) {
throw new JenkinsAPIError(
"Failure Threshold reached, exiting script....."
);
reject(
new JenkinsAPIError(
"Failure Threshold reached, exiting script....."
)
); // Reject with JenkinsAPIError if threshold reached
}
failureCount += 1;
throw new BadGatewayError(
`Wrong http response from host - ${res.statusCode}`
);
reject(
new BadGatewayError(
`Wrong http response from host - ${res.statusCode}`
)
); // Reject with BadGatewayError
default:
throw new JenkinsAPIError(
`Unknown API error code received: ${res.statusCode}`
);
reject(
new JenkinsAPIError(
`Unknown API error code received: ${res.statusCode}`
)
); // Reject with JenkinsAPIError on unknown status
}
})
);
Expand Down

0 comments on commit d115d4a

Please sign in to comment.