Catch non 200 response codes of WhatsApp tool

This commit is contained in:
2024-06-18 21:58:03 +02:00
parent 81e1142533
commit 8a15e8d8a8

View File

@@ -51,8 +51,12 @@ public class WhatsAppNotifier {
.build(); .build();
boolean success = false; boolean success = false;
try { try {
client.send(req, HttpResponse.BodyHandlers.ofString()).body(); int responseCode = client.send(req, HttpResponse.BodyHandlers.ofString()).statusCode();
if (responseCode != 200) {
logger.error("Failed to send WhatsApp message. Response code: " + responseCode);
} else {
success = true; success = true;
}
} catch (Exception e) { } catch (Exception e) {
logger.error("Failed to send WhatsApp message: " + e.getMessage()); logger.error("Failed to send WhatsApp message: " + e.getMessage());
} }