From 67ced02756c6e6bf6b5f68861ccacce60b577c4b Mon Sep 17 00:00:00 2001 From: Lennart Heinrich Date: Wed, 22 Oct 2025 21:29:43 +0200 Subject: [PATCH] error handling --- .../persistence/CommandProcessor.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/main/java/de/infinimotion/persistence/CommandProcessor.java b/src/main/java/de/infinimotion/persistence/CommandProcessor.java index 7cd247c..9183201 100644 --- a/src/main/java/de/infinimotion/persistence/CommandProcessor.java +++ b/src/main/java/de/infinimotion/persistence/CommandProcessor.java @@ -25,14 +25,20 @@ public class CommandProcessor { @Incoming("command") @Outgoing("command-replies") public CommandWrapper process(CommandWrapper request) throws IOException { - ThrowingFunction processor = processors.get(request.getType()); - if (processor == null) { + try { + ThrowingFunction processor = processors.get(request.getType()); + if (processor == null) { + CommandException e = new CommandException(); + e.setException("unknown processor"); + return e.serialize().copyIds(request); + } + + return processor.apply(request).serialize().copyIds(request); + } catch (Throwable t) { CommandException e = new CommandException(); - e.setException("unknown processor"); + e.setException(t.getMessage()); return e.serialize().copyIds(request); } - - return processor.apply(request).serialize().copyIds(request); } @Transactional