According to this article, use the Message field of an Exception class is not a good programming practice.
However, when I try to throw an exception (e.g. ArgumentException
) in my project, how can I add my custom exception information? Should I use Exception.Data
Property?
Instead of using:
throw new ArgumentException("My Custom Info.");
Should I use:
ArgumentException ex = new ArgumentException();
ex.Data["CustomInfo"] = "My Custom Info.";
throw ex;
The code becomes cumbersome, if I don't use Message field.
Is it a good practice not to use Message field of an Exception class?
Thanks in advance.