In my project I was throwing a list of error messages
like this
List<string> errorMessageList = errors[0].Split(new char[] { ',' }).ToList();
throw new WorkflowException(errorMessageList);
and my WorkflowException class looks like this
/// <summary>
/// WorkFlowException class
/// </summary>
public class WorkFlowException : Exception
{
/// <summary>
/// Initializes a new instance of the WorkFlowException class
/// </summary>
/// <param name="message">Error Message</param>
public WorkFlowException(List<string> message)
{
base.Message = message;
}
}
but getting errors while assigning this list of messages to base.Message
can anybody help me to do this?
Exception.Messageis astring, not aList<string>, and it’s read-only, so you have to pass astringto the base class via constructor chaining:Alternatively, you can override the
Messageproperty: