Hi,
I defined an exception in a @CommandHandler
@CommandHandler
public Item(AddItemCommand cmd) {
itemId = cmd.getItemId();
name = cmd.getName();
if(cmd.getName().equals("Monitor"))
throw new IllegalArgumentException("You cannot create a Monitor.");
apply(new ItemAddedEvent(cmd.getItemId(), cmd.getName()));
}
and I want to retrive the ID or the exception If the command fails.
@PostMapping(value = "")
public Future createItem(@RequestParam("itemId")String itemId,
@RequestParam("name")String name){
return commandGateway.send(new AddItemCommand(itemId, name));
}
but I obtain this message:
{
“timestamp”: “2019-02-13T13:41:36.509+0000”,
“status”: 500,
“error”: “Internal Server Error”,
“message”: “AxonServerRemoteCommandHandlingException{message=An exception was thrown by the remote message handling component., errorCode=‘AXONIQ-4002’, server=‘1106@MBP-di-Daniele.fritz.box’}”,
“path”: “/oggetti”
}
Any ideas to improved my solution?
Daniele.