我想将一些自定义错误消息以及引发的异常传递给 elmah 源。例如我有课
public class Activity
{
public string Id { get; set; }
public Committee Committee { get; set; }
public Contact Contact { get; set; }
[Range(1950, 2050, ErrorMessage = "{0} must be between {1} and {2}.")]
[DisplayName("Activity End Date")]
public int? EndDate { get; set; }
[DisplayName("Source")]
public string Source { get; set; }
[DisplayName("Activity Role")]
public string Role { get; set; }
[DisplayName("Comments")]
public string Comments { get; set; }
}
引发异常时,我的异常中没有此类道具值。所以我想将这些值和异常传递给 elmah。
现在我在做
catch (Exception exception)
{
Elmah.ErrorSignal.FromCurrentContext().Raise(exception);
return View("Error");
}
我能怎么做?