Skip to content

Commit

Permalink
fix(webhook): Added better error logging for failed webhook requests
Browse files Browse the repository at this point in the history
Fixes #1081
  • Loading branch information
Göran Sander committed Apr 12, 2024
1 parent dc3b1e1 commit 1c96ed6
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions src/lib/webhook_notification.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,9 +318,28 @@ async function sendOutgoingWebhook(webhookConfig, reloadParams) {
}
}

// eslint-disable-next-line no-await-in-loop
const response = await axios.request(axiosRequest);
globals.logger.debug(`WEBHOOKOUT: Webhook response: ${response}`);
// Capture exception if the webhook call fails, then continue with the next webhook
try {
// eslint-disable-next-line no-await-in-loop
const response = await axios.request(axiosRequest);
globals.logger.debug(`WEBHOOKOUT: Webhook response: ${response}`);
} catch (err) {
if (err.message) {
globals.logger.error(`WEBHOOKOUT: Webhook call failed: ${err.message}`);

// err.response.status 404 could mean that the webhook URL is incorrect
if (err.response && err.response.status === 404) {
globals.logger.error(`WEBHOOKOUT: 404 error could mean that the webhook URL is incorrect`);
}

globals.logger.error(`WEBHOOKOUT: Webhook url: ${axiosRequest.url}`);
globals.logger.error(`WEBHOOKOUT: Webhook config: ${JSON.stringify(webhook, null, 2)}`);
}
// If neither message nor stack is available, just log the error object
if (!err.message && !err.stack) {
globals.logger.error(`WEBHOOKOUT: Webhook call failed: ${JSON.stringify(err, null, 2)}`);
}
}
}
} else {
globals.logger.info('WEBHOOKOUT: No outgoing webhooks to process');
Expand Down

0 comments on commit 1c96ed6

Please sign in to comment.