-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Missing Request Type Exception #49
Comments
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 ìnt |
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 |
Merged the PR |
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)
The text was updated successfully, but these errors were encountered: