Missing Request Type Exception
Thanks again for a great project.
At the moment in Send in Mediator.g.cs the default handler is to ThrowArgumentNullOrInvalidMessage which first casts the message as global::Mediator.IMessage. Since the request doesn't need to be IMessage it can come through as null at that point, and then we get an ArgumentNullException message instead of a missing request type exception.
Possibly the issue I'm referring to could be fixed by not casting to IMessage? This would do MissingMessageHandlerException which would be good enough for my purposes. (I'm not sure if distinguishing between missing handler and a missing request type is possible or sensible, but they look like they could be different things)
(I am on 2.0.27-rc)
Hey, sorry about the delay here.. Is this about having a better error message for when a non-IMessage is sent? E.g. if I tried to send an ìntthrough the overload which takesobject`? I could probably have a better error message for that, maybe even Roslyn diagnostics would be better
Hi - all good.
Yes, this is just about having a better error message. At the moment it is possible to get an ArgumentNullException during the send - and that can just make diagnosing things a bit difficult.
So, in Mediator.sbn-cs if instead of just casting to IMessage and then throwing ArgumentNullException - it could check whether msg was null. The error message could then say that msg.GetType() was not assignable to IMessage to be clearer and help debugging (or something along those lines).
Good point, thanks, will get this sorted as soon as I have time
refactored some error handling here, so it's more specific and clearly defined: #66 will be part of 3.0 release since its a breaking change
Merged the PR