Using generic templates in Command/Query classes, so documenting the returned type for each dispatch/ask invocation is no longer necessary.
Now FindBookQuery strictly returns a Book instance; otherwise, a MissingBookException is thrown.
The MissingBookException is mapped to return a 404 status code, so a clear exception message is now displayed.
Replace CommandHandlerInterface with the AsCommandHandler attribute, and QueryHandlerInterface with the AsQueryHandler attribute. The reason behind this is the fact that these interfaces have no contract; they are used as metadata to configure the messenger handler only. So, in this case, we can now use attributes instead as they are intended for that purpose.
This proposal contains several improvements:
FindBookQuery
strictly returns aBook
instance; otherwise, aMissingBookException
is thrown.MissingBookException
is mapped to return a 404 status code, so a clear exception message is now displayed.CommandHandlerInterface
with theAsCommandHandler
attribute, andQueryHandlerInterface
with theAsQueryHandler
attribute. The reason behind this is the fact that these interfaces have no contract; they are used as metadata to configure the messenger handler only. So, in this case, we can now use attributes instead as they are intended for that purpose.