在项目中,我被扔的错误消息列表抛出错误列表时出错?
这样
List<string> errorMessageList = errors[0].Split(new char[] { ',' }).ToList();
throw new WorkflowException(errorMessageList);
和我WorkflowException类看起来像这样
/// <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;
}
}
,但得到的错误,同时指派消息这份名单消息 任何人都可以帮助我做到这一点?
而不是只显示列表中的第一条消息,我会将每个元素连接成单个字符串,以便您不会丢失任何在抛出异常时的消息。 – 2011-04-12 04:46:11
OP最初在逗号分隔的字符串中有所有错误。你也可以有一个'Messages'属性。 – 2011-04-12 04:47:29