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