Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Exception handling

Reply
Thread Tools

Exception handling

 
 
tshad
Guest
Posts: n/a
 
      02-06-2006
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.ConfigurationSe ttings.AppSettings("MM_CONNECTION_STRING_ftsolutio ns"))

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.AppRelativeCurrentExecutionFilePat h()
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


 
Reply With Quote
 
 
 
 
tshad
Guest
Posts: n/a
 
      02-06-2006
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

"tshad" <> wrote in message
news:...
>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.ConfigurationSe ttings.AppSettings("MM_CONNECTION_STRING_ftsolutio ns"))
>
> 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.AppRelativeCurrentExecutionFilePat h()
> 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
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
signal handling and (structured) exception handling Peter C++ 34 10-17-2009 10:03 AM
python list handling and Lisp list handling Mark Tarver Python 22 04-26-2009 09:36 PM
Exception of type 'System.Web.HttpUnhandledException' wasthrown.Exception has been thrown by the target of an invocation.System.WebSystem.Exception jobs ASP .Net 1 11-16-2007 05:57 PM
while executing my client program i get the exception javax.naming.LinkException: [Root exception is javax.naming.LinkException: [Root exception is javax.naming.NameNotFoundException: remaining if plz anybody know how to solve this problem then mahesh Java 0 03-08-2007 12:26 PM
SoapExtension for Global Exception handling; but prevent exception from propagating!! VSK ASP .Net Web Services 0 07-29-2003 05:39 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57