Results 1 to 4 of 4

Thread: error working with exceptions

  1. #1

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428

    Talking 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:
    1. Try
    2.             Dim img As Image = Image.FromFile(imagePath)
    3.             Dim frm As New frmImage(img, imagePath)
    4.             frm.MdiParent = Me
    5.             frm.Show()
    6.             Return frm
    7.         Catch ex As Exception When [b]Globals.LogError(ex)[/b]
    8.         Catch ex As IO.FileNotFoundException
    9.            MessageBox.Show("Error loading image. The following file could not be found: " & ex.FileName, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
    10.         [b]Catch ex As Exception[/b]
    11.             MessageBox.Show("Error loading image: " & ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
    12.             ' StackTrace has a value here
    13.         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?

    ignore the code inside the try catch block...
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    I don't think ex is assigned to anything until its inside the Catch. That is just a guess really. Can you get the message or other parts of the exception in the LogError method?

  3. #3

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    Originally posted by Edneeis
    I don't think ex is assigned to anything until its inside the Catch. That is just a guess really. Can you get the message or other parts of the exception in the LogError method?
    well yeah that's the weird part. I can get ex.Message and I can also get the type of the exception. This doesnt make sense! why would the other variables of ex be empty?
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  4. #4
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    I dunno that is wierd.?!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width