Skip to content

Commit

Permalink
fix(webhooks): propagate ex instead of handling them for logging (#13) (
Browse files Browse the repository at this point in the history
  • Loading branch information
vincejv authored Nov 2, 2022
1 parent 7767c44 commit 0693c6f
Showing 1 changed file with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,17 @@ public Uni<Void> process(MetaMsgEvtDto evt) {
// process load
.chain(session -> processLoadQuery(login, session, evt))
// login failures
.onFailure(ApiSvcEx.class).recoverWithUni(ex -> handleApiEx(evt, ex))
.onFailure(ApiSvcEx.class).call(ex -> handleApiEx(evt, ex))
// failures to send messenger
.onFailure().recoverWithItem(this::handleMsgEx)
.onFailure().invoke(this::handleMsgEx)
.replaceWithVoid();
})
.onFailure(ex -> ex instanceof MongoWriteException wEx &&
wEx.getError().getCategory().equals(ErrorCategory.DUPLICATE_KEY))
.recoverWithUni(throwable -> {
Log.warn("Received duplicate mid: " + evt.getMetaMsgId());
return Uni.createFrom().voidItem();
});
}).onFailure().recoverWithItem(this::handleMsgEx);
.invoke(throwable ->
Log.warn("Received duplicate mid: " + evt.getMetaMsgId())
);
}).onFailure().invoke(this::handleMsgEx);
}
return Uni.createFrom().voidItem();
}
Expand All @@ -113,9 +112,8 @@ private Uni<Void> processLoadQuery(LoginDto login, RespDto<SessionDto> session,
return sendMsgrMsg(evt, session.getStatus());
}

private Void handleMsgEx(Throwable sendMsgEx) {
private void handleMsgEx(Throwable sendMsgEx) {
Log.error("Message sending failed: " + sendMsgEx.getMessage(), sendMsgEx);
return null;
}

private Uni<Void> handleApiEx(MetaMsgEvtDto evt, Throwable ex) {
Expand Down

0 comments on commit 0693c6f

Please sign in to comment.