(PeteCresswell) said:
Per Mr. Arnold:
I think it's starting to soak in.
Is it common practice to have a single error handling routine
that is called by "Catch" - and which writes relevant info to a
.txt file?
You surround any code that *might* fail at runtime with a Try...Catch block.
Because some code can fail for different reasons, you may choose to have
several Catch blocks stemming from just one Try, as in:
Try
'Place code that *may* fail at runtime here
Catch ex As OverflowException
'Deal with Overflow exceptions that get caught here
Catch ex As InvalidCastException
'Deal with casting exceptions that get caught here
Catch ex As Exception
'Deal with any exception that hasn't already been caught here
End Try
Remember that Try...Catch is not a substitute for writing good code. When I
say you try code that *might* fail, I mean *might* fail, through no fault of
your code. Things like the network being down or a server being offline
could certainy cause your code to fail even though you've coded your end
correctly. Attempting to divide some user input by 3 without checking the
user input to see if it is a non-zero number first is NOT what Try...Catch
is for.
What you actually do in the Catch blocks is up to you. Many people write
information about the exception into the Event log, rather than a text file,
but it's up to you.
-Scott