LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Error Handling Using Connections

Solved!
Go to solution

What is the recommended way to handle errors and successfully close connections such as TCP/IP communication or a connection to a database.

 

In a text based language I would typically do the following:

 

Connection myConnection.

Try

{

    myConnection.Open();

    myConnection.DoStuff();

}

Catch( someError)

{

}

Finally

{

    myConnection.Close();

}

 

It is not clear to me in LabVIEW if I pass the error to the close connection if that VI will run.

IE)

Error Passed Through.png

 

or

Error Not Passed Through.png

 

Ideally when dealing with the error I would like to return my program back into a known state which in many cases is a closed connection.

0 Kudos
Message 1 of 3
(2,555 Views)
Solution
Accepted by topic author Rannoch

NI stuff is usually pretty good about running Close VIs even if an error occurs.

In your example, the help for TCP Close explicitly mentions that the VI will run normally even if an error is wired into it.

 

Check the help files for default behavior and if you find any that don't attempt cleanup, I think you should report it as a bug.

Message 2 of 3
(2,548 Views)

Check out this Nugget from Darren:Functions that execute even with an incoming error


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 3 of 3
(2,526 Views)