Try-catch all

Hi everyone,

got a quick question about Try-Catch blocks. I often need to iterate through objects and do some processing, but simply want each iteration to continue if an exception arises. I’m using try-catch blocks for this. I’m not trying to handle the exception, just want to prevent it from stopping the iteration. Something like:

for each f as folderItem in arrayOfFiles
      'do some processing which could create potential exceptions 
     'no code here, really, but just continue the loop with the next item
   end try

Since I’m not specifying any type of exception in the catch statement, I assume it’s catching any runtime exception. Of course, I don’t have access to the actual exception instance so cannot make tests on it, which is fine for me in this particular case.

What makes me uncertain is the language reference mentions that : [quote]You should try to avoid catching the RuntimeException superclass as this could cause prevent threads from properly being killed or apps from quitting if an exception is raised during those events.[/quote]

So is there another way to go about this other that checking all foreseeable exceptions that could be raised by the code and re-raising the others?

well WHY are you catching “everything under the sun” ?
I’d catch file io type exceptions if you just want to ignore those and not all the rest
catch only what you truly want to and not everything otherwise you can cause your own worst problems when things dont work and you forget you have a spot that catches everything

Alright… It does make perfect sense. I had this little voice in my head telling me the same thing you just said. I guess I was wishing for a quick and dirty way… without the dirty part :slight_smile: