how to handle errors

neginf

New member
Joined
Mar 10, 2010
Messages
1
Programming Experience
10+
I am making a vb.net program that calls several other subprograms. None of them effect the other.
If there is an error in 1 of them, how do you record the error but continue on to the next subprogram with out stopping everything ?
 
it all depends on what you are trying to do, without seeing some code, it is difficult to know what you require... But an example of how to carry on when running into errors is simple.

Here is an example of something you might do

VB.NET:
    Private Sub MainCodeToExecute()
        If ConnectToExternalProgram() Then
            ' Do whatever it is you needed to do
        End If

        ' Code that you execute regardless
    End Sub

    Private Function ConnectToExternalProgram() As Boolean
        Try
            ' Code to connect to external program

            Return True
        Catch
            Return False
        End Try
    End Function

Basically by putting my try catch block in a seperate function and handle any errors that might occur and the main Sub will continue executing regardless.

I hope this is what you meant.
 
Back
Top