T
tshad
I am trying to set up an exception logging and have some code from a book I
am using.
It all seems to work except for the ID I am setting up for handling
Exception Chains (I am only getting one entry per error - so I don't know if
the Chain is even working).
I have a field in my database as:
ChainID uniqueidentifier.
What I am putting here is a GUID.
But all the entries show the field as blank (empty)
I am doing a Guid.NewGuid):
Dim chainID As Guid = Guid.NewGuid()
So I assume I am getting an ID and putting it in the Object, which is
putting it in the file:
exLog.ChainID = chainID
Why is this?
****************************************************************************
Public Shared Sub Log(ByVal ex As Exception)
Dim exLog As New ExceptionLog
Dim parentID As Integer = 0
Dim chainID As Guid = Guid.NewGuid()
Dim dbConn As SqlConnection = New
SqlConnection(System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_STRING_ftsolutions"))
dbConn.Open()
'Iterate through all of the exceptions in the exception chain
While Not ex Is Nothing
'Create a new Exception Log object for the exception
exLog = New ExceptionLog()
'Acquire the user name
If Current.User.Identity.IsAuthenticated Then
exLog.UserID = Current.User.Identity.Name
Else
exLog.UserID = "<Anonymous User>"
End If
exLog.ParentID = parentID
exLog.MachineName = Current.Server.MachineName
exLog.UserAgent = Current.Request.UserAgent
exLog.ExceptionDate = Now
exLog.ExceptionType = ex.GetType.ToString
exLog.ExceptionMessage = ex.Message
' exLog.Page =
Current.Request.AppRelativeCurrentExecutionFilePath()
exLog.StackTrace = ex.StackTrace
exLog.QueryStringData = GetQuerystringData()
exLog.FormData = GetFormData()
exLog.ChainID = chainID
'Save Exception Log, Get New ParentID, Get Next Inner Exception
If exLog.Save(dbConn) Then
parentID = exLog.ExceptionID
ex = ex.InnerException
Else
ex = Nothing
End If
End While
dbConn.Close()
End Sub
****************************************************************************
Thanks,
Tom
am using.
It all seems to work except for the ID I am setting up for handling
Exception Chains (I am only getting one entry per error - so I don't know if
the Chain is even working).
I have a field in my database as:
ChainID uniqueidentifier.
What I am putting here is a GUID.
But all the entries show the field as blank (empty)
I am doing a Guid.NewGuid):
Dim chainID As Guid = Guid.NewGuid()
So I assume I am getting an ID and putting it in the Object, which is
putting it in the file:
exLog.ChainID = chainID
Why is this?
****************************************************************************
Public Shared Sub Log(ByVal ex As Exception)
Dim exLog As New ExceptionLog
Dim parentID As Integer = 0
Dim chainID As Guid = Guid.NewGuid()
Dim dbConn As SqlConnection = New
SqlConnection(System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_STRING_ftsolutions"))
dbConn.Open()
'Iterate through all of the exceptions in the exception chain
While Not ex Is Nothing
'Create a new Exception Log object for the exception
exLog = New ExceptionLog()
'Acquire the user name
If Current.User.Identity.IsAuthenticated Then
exLog.UserID = Current.User.Identity.Name
Else
exLog.UserID = "<Anonymous User>"
End If
exLog.ParentID = parentID
exLog.MachineName = Current.Server.MachineName
exLog.UserAgent = Current.Request.UserAgent
exLog.ExceptionDate = Now
exLog.ExceptionType = ex.GetType.ToString
exLog.ExceptionMessage = ex.Message
' exLog.Page =
Current.Request.AppRelativeCurrentExecutionFilePath()
exLog.StackTrace = ex.StackTrace
exLog.QueryStringData = GetQuerystringData()
exLog.FormData = GetFormData()
exLog.ChainID = chainID
'Save Exception Log, Get New ParentID, Get Next Inner Exception
If exLog.Save(dbConn) Then
parentID = exLog.ExceptionID
ex = ex.InnerException
Else
ex = Nothing
End If
End While
dbConn.Close()
End Sub
****************************************************************************
Thanks,
Tom