<p>With default flags, the C++ <ahref="../api_reference/CXX/env.html"class="olink">DbEnv</a> and <ahref="../api_reference/CXX/db.html"class="olink">Db</a> classes
can throw exceptions from their constructors. For example, this can
happen if invalid parameters are passed in or the underlying C
structures could not be created. If the objects are created in an
environment that is not configured for exceptions (that is, the
<ahref="../api_reference/CXX/envcreate.html#env_DB_CXX_NO_EXCEPTIONS"class="olink">DB_CXX_NO_EXCEPTIONS</a> flag is specified), errors from the
constructor will be returned when the handle's open method is called.</p>
<p>In addition, the behavior of the <ahref="../api_reference/CXX/env.html"class="olink">DbEnv</a> and <ahref="../api_reference/CXX/db.html"class="olink">Db</a>
destructors has changed to simplify exception handling in applications.
The destructors will now close the handle if the handle's close method
was not called prior to the object being destroyed. The return value
of the call is discarded, and no exceptions will be thrown.
Applications should call the close method in normal situations so any
errors while closing can be handled by the application.</p>
<p>This change allows applications to be structured as follows:</p>
<preclass="programlisting">try {
DbEnv env(0);
env.open(/* ... */);
Db db(&env, 0);
db.open(/* ... */);
/* ... */
db.close(0);
env.close(0);
} catch (DbException &dbe) {
// Handle the exception, the handles have already been closed.