Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Writing to debug log

Writing to debug log

Scheduled Pinned Locked Moved Visual Basic
debugginghelpquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    cstrader232
    wrote on last edited by
    #1

    I have some code within try...catch blocks that might not always execute properly. One error that might occur is a System.InvalidCastException error. I trap the error, but can I prevent the error from being written to the log? Thanks

    L B 2 Replies Last reply
    0
    • C cstrader232

      I have some code within try...catch blocks that might not always execute properly. One error that might occur is a System.InvalidCastException error. I trap the error, but can I prevent the error from being written to the log? Thanks

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      :confused: :confused: And who is writing those exceptions to the log? remove the code that does that. Or, much better, do what it takes not to have those casting exceptions in the first place (can't provide detailed help witout seeing the offensive code).

      Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum

      Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

      1 Reply Last reply
      0
      • C cstrader232

        I have some code within try...catch blocks that might not always execute properly. One error that might occur is a System.InvalidCastException error. I trap the error, but can I prevent the error from being written to the log? Thanks

        B Offline
        B Offline
        Bernhard Hiller
        wrote on last edited by
        #3

        Catch the specific Exceptions first, then the generic Exception:

        Try
        'some code
        Catch System.InvalidCastException
        'do something
        Catch Exception
        'log it and do something
        End Try

        But of course you should better find the reason for those InvalidCastException, and get rid of them.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups