下面,爲什麼Throw
沒有保留我的原始行號?
如果我運行DerivedPage,我的日誌文件列出了第7行的錯誤。
不應該說第4行嗎?這是有道理的,如果我有Throw ex
,但我不知道。
是不是Throw
本身只是應該重新拋出並冒出錯誤?在asp.net中拋出問題
如果我在DerivedPage中完全刪除Try...Catch
塊,那麼我的日誌文件正確列出3作爲錯誤行,但我無法記錄任何錯誤信息。
我該如何維護我的DerivedPage,還有我的日誌保持正確的行號?
Public Class DerivedPage Inherits BasePage
Page_Load(o,e)
Try
Dim a = 3 -"a"
Catch ex As Exception
log.Info(...)
Throw
End Try
End Class
基頁:
Public Class BasePage
Protected Overrides Sub OnError(e)
MyBase.OnError(e)
log.Error(Me.GetType(), Server.GetLastError)
End Sub
End Class
編輯:log.Error
確實輸出的InnerException如果它存在。它在這種情況下。但是,InnerException的堆棧跟蹤不包含行號,只是異常詳細信息。
您是否檢查過由GetLastError返回的異常? – tomasmcguinness 2011-04-14 15:15:06