Skip to content

Commit 81d3511

Browse files
committed
fix: Substantially improve error messages if the pact publisher API fails
1 parent 4a100bb commit 81d3511

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/publisher.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,15 @@ export class Publisher {
111111
instance.once('close', (code) => {
112112
const o = output.join('\n');
113113
const pactUrls = /https?:\/\/.*\/pacts\/.*$/gim.exec(o);
114-
if (code !== 0 || !pactUrls) {
115-
logger.error(`Could not publish pact:\n${o}`);
116-
return reject(new Error(o));
114+
if (code !== 0) {
115+
const message = `Pact publication failed with non-zero exit code. Full output was:\n${o}`;
116+
logger.error(message);
117+
return reject(new Error(message));
118+
}
119+
if (!pactUrls) {
120+
const message = `Publication appeared to fail, as we did not detect any pact URLs in the following output:\n${o}`;
121+
logger.error(message);
122+
return reject(new Error(message));
117123
}
118124

119125
logger.info(o);

0 commit comments

Comments
 (0)