Exception handling

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
 
T

tshad

I found that the blank GUID was actually only showing that way if you did a
Return All Rows from Enterprise manager. A "Select * ..." actually works
fine.

I still don't know why I am not getting any chains. I always get only one.

I am doing:

While Not ex Is Nothing

'Create a new Exception Log object for the exception
exLog = New ExceptionLog()
ex = ex.InnerException

End While

But it always only does one exception - no chain.

Is this something only available in 2.0?

Thanks,

Tom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,539
Members
45,024
Latest member
ARDU_PROgrammER

Latest Threads

Top