Skip to content

Commit 2091431

Browse files
committed
Unified error logging for transfer method
1 parent f9fb5ae commit 2091431

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

server/src/main/java/com/exactpro/blockchain/api/client/ClientHandler.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ public Mono<ServerResponse> transfer(ServerRequest request) {
8383
try {
8484
transferToSave = converter.convertToTransfer(customerCreditTransfer, TransferStatus.PENDING).get(0);
8585
} catch (IllegalArgumentException e) {
86-
logger.error("Failed to convert CustomerCreditTransfer to Transfer", e);
8786
return Mono.error(new RuntimeException("Failed to convert CustomerCreditTransfer to Transfer", e));
8887
}
8988

@@ -93,7 +92,6 @@ public Mono<ServerResponse> transfer(ServerRequest request) {
9392
try {
9493
encodedTransfer = xmlCodec.encode(customerCreditTransfer);
9594
} catch (JAXBException | TransformerException e) {
96-
logger.error("Failed to encode to XML", e);
9795
return Mono.error(new RuntimeException("Failed to encode to XML", e));
9896
}
9997

@@ -105,15 +103,17 @@ public Mono<ServerResponse> transfer(ServerRequest request) {
105103
.onErrorResume(e -> {
106104
transfer.setStatus(TransferStatus.FAILED);
107105
transferRepository.save(transfer).subscribe();
108-
logger.error("Failed to send message to Kafka", e);
109106
return Mono.error(new RuntimeException("Kafka send failed", e));
110107
})
111108
.then(ServerResponse.accepted()
112109
.bodyValue(MessageFormat.format("Transfer successful for client {0}. Details: {1}", clientId, transferDetails)));
113110
});
114111
});
115112
})
116-
.onErrorResume(RuntimeException.class, e -> ServerResponse.status(500).bodyValue("Internal Server Error"))
113+
.onErrorResume(RuntimeException.class, e -> {
114+
logger.error(e.getMessage(), e);
115+
return ServerResponse.status(500).bodyValue("Internal Server Error");
116+
})
117117
.switchIfEmpty(ServerResponse.badRequest().bodyValue("Invalid request"));
118118
}
119119

0 commit comments

Comments
 (0)