error working with exceptions
I dont know why I cant get the stacktrace of the error this way:
I'm doing error handling this way, and the Globals.LogError function below always returns false:
VB Code:
Try
Dim img As Image = Image.FromFile(imagePath)
Dim frm As New frmImage(img, imagePath)
frm.MdiParent = Me
frm.Show()
Return frm
Catch ex As Exception When [b]Globals.LogError(ex)[/b]
Catch ex As IO.FileNotFoundException
MessageBox.Show("Error loading image. The following file could not be found: " & ex.FileName, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
[b]Catch ex As Exception[/b]
MessageBox.Show("Error loading image: " & ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
' StackTrace has a value here
End Try
My problem is that when I check ex.StackTrace in my LogError function, its value is Nothing. But when I check it in the last Catch clause, it has a value. I dont know, is there a reason why this is happening? :confused: :confused: :confused:
ignore the code inside the try catch block...