实现了对Exception的存储,以达到向外层传送的目的
如:
try {
thisValue = conv.ConvertFrom(valueshttpKey);
property.SetValue(value, thisValue, null);
}
catch (FormatException e) {
string message = property.Name + " is not a valid " + property.PropertyType.Name + "; " + e.Message;
if (ex == null)
ex = new PopulateTypeException("Errors occurred during object binding - review the LoadExceptions property of this exception for more details");
ExceptionInfo info = new ExceptionInfo();
info.AttemptedValue = thisValue;
info.PropertyName = property.Name;
info.ErrorMessage = message;
ex.LoadExceptions.Add(info);
}
本类有以下属性:
public string PropertyName {get;set;}
public object AttemptedValue {get;set;}
public string ErrorMessage {get;set;}