Handle connection exceptions
- Last Updated: February 11, 2026
- 1 minute read
- OpenEdge
- Version 13.0
- Documentation
The creation of a connection to an application server should be wrapped with exception-handling code to avoid memory leaks and unnecessary allocation of client and server resources. Also, information received from a caught exception can be valuable in tracing and fixing connection errors.
The following is an example of handling connection exceptions:
|
This example executes the connect in the try block.
If there is an exception thrown by the process, the catch block
displays the exception message to the user.
The catch block is specifically catching the
ConnectException. For more information on .NET Open Client exceptions, see
Handle Errors.
The finally block ensures that the Dispose(
) method is called on the AppObject. By putting the Dispose(
) method in the finally block, you ensure
that the connection is closed whether an exception occurs or the
connect is successful.