【发布时间】:2011-06-27 04:08:30
【问题描述】:
捕获一个异常然后抛出另一个异常是个好主意吗?
像这样:
Try
' Do operation xxx
Catch ex As Exception
' Operation xxx failed, need to execute cleanup
' But now I've caught this exception outside of my main control logic,
' so I would like to re-throw it
Throw New ApplicationException("XXX failed")
End Try
这样做的原因是,虽然我在更高级别的逻辑上捕获了我的异常(以确保我可以正确记录它),但我需要在异常事件中执行一些我只能在我的内部执行的操作类/函数。
你能想出什么原因/场景说明这是个坏主意吗?
【问题讨论】:
-
你失去了原来的堆栈跟踪抛出这样的
标签: .net vb.net exception-handling