Skip to content

Commit

Permalink
fix: Substantially improve error messages if the pact publisher API f…
Browse files Browse the repository at this point in the history
…ails
  • Loading branch information
TimothyJones committed Oct 18, 2021
1 parent 4a100bb commit 81d3511
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/publisher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,15 @@ export class Publisher {
instance.once('close', (code) => {
const o = output.join('\n');
const pactUrls = /https?:\/\/.*\/pacts\/.*$/gim.exec(o);
if (code !== 0 || !pactUrls) {
logger.error(`Could not publish pact:\n${o}`);
return reject(new Error(o));
if (code !== 0) {
const message = `Pact publication failed with non-zero exit code. Full output was:\n${o}`;
logger.error(message);
return reject(new Error(message));
}
if (!pactUrls) {
const message = `Publication appeared to fail, as we did not detect any pact URLs in the following output:\n${o}`;
logger.error(message);
return reject(new Error(message));
}

logger.info(o);
Expand Down

0 comments on commit 81d3511

Please sign in to comment.