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
More descriptive InvalidOperationException message in MetaBodyWriter class #1058
Comments
I ended up creating this PR #1059 |
andersjonsson
added a commit
that referenced
this issue
May 17, 2024
…xception-messages-in-MetaBodyWriter #1058 - More descriptive InvalidOperationException messages in MetaBodyWriter class
PR #1059 was merged so I am closing this issue. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Issue description
Hello,
yesterday I encountered an exception with a really ambiguous message of what went wrong.
The InvalidOperationException was thrown in MetaBodyWriter class on line 134.
It's in this method:
private static string GetMessageContractBodyName(Type type)
{
if (!TryGetMessageContractBodyMemberInfo(type, out var memberInfo))
{
throw new InvalidOperationException(nameof(type));
}
return memberInfo.Name;
}
The exception thrown with omitted stack trace looked like this:
Unhandled exception. System.InvalidOperationException: type
Proposed solution
I would like to propose using
type.ToString()
instead ofnameof(type)
as the InvalidOperationException message.So the exception message would look something like this:
System.InvalidOperationException: The.Types.Namespace.TypeClass
Or even better, add a descriptive message of what is wrong with the
type
argument and add it'stype.ToString()
to the new message.Other remarks
The same problem is present in the same class in an another method called
GetMessageContractBodyType
at line 120I could fix this myself, but if you want more descriptive messages I would need examples.
I apologize but English is not my main language. If anything I wrote is not clear I would be more than happy to clarify.
Thanks!
The text was updated successfully, but these errors were encountered: