error handling

This commit is contained in:
2025-10-22 21:29:43 +02:00
parent 032e3ed227
commit 67ced02756

View File

@@ -25,14 +25,20 @@ public class CommandProcessor {
@Incoming("command") @Incoming("command")
@Outgoing("command-replies") @Outgoing("command-replies")
public CommandWrapper process(CommandWrapper request) throws IOException { public CommandWrapper process(CommandWrapper request) throws IOException {
ThrowingFunction<CommandWrapper, Command, IOException> processor = processors.get(request.getType()); try {
if (processor == null) { ThrowingFunction<CommandWrapper, Command, IOException> 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(); CommandException e = new CommandException();
e.setException("unknown processor"); e.setException(t.getMessage());
return e.serialize().copyIds(request); return e.serialize().copyIds(request);
} }
return processor.apply(request).serialize().copyIds(request);
} }
@Transactional @Transactional