我有一个方法如下:捕捉异常,日志记录和重新抛出 - 我有这个错误吗?
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公开。
好吧,所以你做的第一点是我认为我会改变我的代码。 WCF将被Java客户端使用 - 我会遇到问题吗? – youwhut 2010-11-10 09:28:31
其实下面的答案是一个很好的帮助:http://stackoverflow.com/questions/1369882/wcf-web-service-custom-exception-error-to-client/1369956#1369956 – youwhut 2010-11-10 09:40:19