@erip if you need to return a custom exception for invalid command you could use ctx.commandFailed and provide a custom exception there.
It will not be a default one but you need to specify it explicitly.
Is this what you need or?
Sorry, I wasn’t very clear. If I have a large number of commands, it becomes cumbersome to enumerate them all with a ctx.commandFailed in the following way:
def awaitingResponse() = Actions()
/* email sent; awaiting a verification command. All else are bad... */
.onCommand[A, B] {
case (_: A, ctx, _) => ctx.commandFailed(...)
}
.onCommand[C, D] {
case (_: C, ctx, _) => ctx.commandFailed(...)
}
@erip so you need a custom PersistentEntity.UnhandledCommandException per behavior so you can distringuish in what state entity is on ask side if command is not implemented.
I did not find anything like this available.