Skip to content

Commit

Permalink
Improve system error notification message for failed CustomHTTPNotifi…
Browse files Browse the repository at this point in the history
…ons (#19998)

* Improve system error notification message for failed CustomHTTPNotifiations
  • Loading branch information
kingzacko1 authored Jul 26, 2024
1 parent 5216963 commit 45a123c
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,13 @@ public void execute(EventNotificationContext ctx) throws TemporaryEventNotificat
final OkHttpClient httpClient = selectClient(config);
try (final Response r = httpClient.newCall(builder.build()).execute()) {
if (!r.isSuccessful()) {
errorMessage = "Expected successful HTTP response [2xx] but got [" + r.code() + "]. " + config.url();
createSystemErrorNotification(errorMessage + "for notification [" + ctx.notificationId() + "]");
final String errorDetail = r.body() == null ? " URL: " + config.url() : " " + r.body().string();
errorMessage = "Expected successful HTTP response [2xx] but got [" + r.code() + "]." + errorDetail;
createSystemErrorNotification(errorMessage + " for notification [" + ctx.notificationId() + "]");
throw new PermanentEventNotificationException(errorMessage);
}
} catch (IOException e) {
createSystemErrorNotification("Error: " + e.getMessage() + " for notification [" + ctx.notificationId() + "]");
throw new PermanentEventNotificationException(e.getMessage());
}
}
Expand Down

0 comments on commit 45a123c

Please sign in to comment.