Skip to content

Commit

Permalink
Updated the error handling in case the error reporter is null (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
maniskum authored May 31, 2024
1 parent 849f1fa commit 57092d0
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,21 @@ public void publishData(List<Pair<String, SinkRecord>> messages) throws AEPStrea
LOG.error("Failed to publish data to Adobe Experience Platform", jsonException);
if (Objects.nonNull(errorReporter)) {
messages.forEach(message -> errorReporter.report(message.getValue(), jsonException));
} else {
throw new AEPStreamingException("Failed to publish invalid JSON", jsonException);
}
} catch (HttpException httpException) {
LOG.error("Failed to publish data to Adobe Experience Platform", httpException);

final int responseCode = httpException.getResponseCode();
if (Objects.nonNull(errorReporter)) {
messages.forEach(message -> errorReporter.report(message.getValue(), httpException));
} else {
if (HttpUtil.is500(responseCode)) {
throw new AEPStreamingException("Failed to publish", httpException);
}
}
final int responseCode = httpException.getResponseCode();

if (HttpUtil.isUnauthorized(responseCode)) {
throw new AEPStreamingException("Failed to publish", httpException);
}
Expand Down

0 comments on commit 57092d0

Please # to comment.