Shr*_*oid 5 c# exception-handling exception
我知道这可能有点奇怪,但怀疑是一个疑问...在下列情况下会发生什么......
private void SendMail()
{
try
{
//i try to send a mail and it throws an exception
}
catch(Exception ex)
{
//so i will handle that exception over here
//and since an exception occurred while sending a mail
//i will log an event with the eventlog
//All i want to know is what if an exception occurs here
//while writing the error log, how should i handle it??
}
}
Run Code Online (Sandbox Code Playgroud)
谢谢.
我个人会用另一个 try\catch 语句来包装写入事件日志的调用。
然而,最终这取决于您的规格。如果将故障写入事件日志对于系统至关重要,那么您应该允许抛出它。但是,根据您的示例,我怀疑这是否是您想要做的。
| 归档时间: |
|
| 查看次数: |
1243 次 |
| 最近记录: |