I am throwing ArgumentNullException in part of my code in C#. I want to catch and display the error message of my exception. But without the parameter name. I want to pass the parameter name to the exception constructor.
throw new ArgumentNullException("myParameter", errorMessageStringVariable);
If I call error.Message
I get something like
errorMessageStringVariable parameter name: myParameter
I want to display only the errorMessageStringVariable. Is it possible using ArgumentNullException, without some kind of formating on the error.Message?
ArgumentException
? – Szczecin