【发布时间】:2010-11-10 09:20:38
【问题描述】:
我有一个方法如下:
Public Sub Send()
Dim caughtException As Exception = Nothing
Try
//Attempt action.
Catch ex As Exception //Custom exceptions which can be thrown all inherit from Exception.
//Instantiate error object to be logged.
caughtException = ex
End Try
//Log action and if there is an error log this too.
If caughtException IsNot Nothing Then Throw caughtException
End Sub
我必须为报告记录错误,经过研究,重新抛出异常是正确的做法。我关心的是堆栈信息的保存。
为了保持代码干燥,我将操作记录在一个地方 - 在捕获异常之后。
此功能最终通过 WCF 公开。
【问题讨论】:
标签: .net vb.net exception-handling