mirror of
https://github.com/berkeleydb/libdb.git
synced 2024-11-17 01:26:25 +00:00
152 lines
6.9 KiB
HTML
152 lines
6.9 KiB
HTML
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|||
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|||
|
<head>
|
|||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
|||
|
<title>Chapter 6. The DbException Class</title>
|
|||
|
<link rel="stylesheet" href="apiReference.css" type="text/css" />
|
|||
|
<meta name="generator" content="DocBook XSL Stylesheets V1.73.2" />
|
|||
|
<link rel="start" href="index.html" title="Berkeley DB C++ API Reference" />
|
|||
|
<link rel="up" href="index.html" title="Berkeley DB C++ API Reference" />
|
|||
|
<link rel="prev" href="envversion.html" title="DbEnv::version()" />
|
|||
|
<link rel="next" href="dbdeadlock.html" title="DbDeadlockException" />
|
|||
|
</head>
|
|||
|
<body>
|
|||
|
<div xmlns="" class="navheader">
|
|||
|
<div class="libver">
|
|||
|
<p>Library Version 11.2.5.2</p>
|
|||
|
</div>
|
|||
|
<table width="100%" summary="Navigation header">
|
|||
|
<tr>
|
|||
|
<th colspan="3" align="center">Chapter 6. The DbException Class</th>
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td width="20%" align="left"><a accesskey="p" href="envversion.html">Prev</a> </td>
|
|||
|
<th width="60%" align="center"> </th>
|
|||
|
<td width="20%" align="right"> <a accesskey="n" href="dbdeadlock.html">Next</a></td>
|
|||
|
</tr>
|
|||
|
</table>
|
|||
|
<hr />
|
|||
|
</div>
|
|||
|
<div class="chapter" lang="en" xml:lang="en">
|
|||
|
<div class="titlepage">
|
|||
|
<div>
|
|||
|
<div>
|
|||
|
<h2 class="title"><a id="dbexception"></a>Chapter 6. The DbException Class</h2>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<pre class="programlisting">#include <db_cxx.h>
|
|||
|
class DbException {
|
|||
|
public:
|
|||
|
int get_errno() const;
|
|||
|
virtual const char *what() const;
|
|||
|
DbEnv *get_env() const;
|
|||
|
}; </pre>
|
|||
|
<p>
|
|||
|
This information describes the <code class="classname">DbException</code> class and how
|
|||
|
it is used by the various Berkeley DB classes.
|
|||
|
</p>
|
|||
|
<p>
|
|||
|
Most methods in the Berkeley DB classes return an <code class="literal">int</code>, but also throw
|
|||
|
an exception. This allows for two different error behaviors. By default, the Berkeley DB
|
|||
|
C++ API is configured to throw an exception whenever a serious error occurs. This
|
|||
|
generally allows for cleaner logic for transaction processing because a try block can
|
|||
|
surround a single transaction. Alternatively, Berkeley DB can be configured to not throw
|
|||
|
exceptions, and instead have the individual function return an error code, by setting
|
|||
|
the <a class="link" href="envcreate.html#env_DB_CXX_NO_EXCEPTIONS">DB_CXX_NO_EXCEPTIONS</a>
|
|||
|
for the <a class="xref" href="dbcreate.html" title="Db">Db</a> and
|
|||
|
<a class="xref" href="envcreate.html" title="DbEnv">DbEnv</a> constructors.
|
|||
|
</p>
|
|||
|
<p>
|
|||
|
A <code class="classname">DbException</code> object contains an informational string, an
|
|||
|
<code class="literal">errno</code>, and a reference to the environment from which the exception
|
|||
|
was thrown. The <code class="literal">errno</code> can be obtained by using the
|
|||
|
<code class="methodname">DbException::get_errno()</code> method, and can be used, in standard
|
|||
|
cases, to determine the type of the exception. The informational string can be obtained
|
|||
|
by using the <code class="methodname">DbException::what()</code>. And, the environment can be
|
|||
|
obtained using the <code class="methodname">DbException::get_env()</code> method.
|
|||
|
</p>
|
|||
|
<p>
|
|||
|
We expect in the future that this class will inherit from the standard class exception,
|
|||
|
but certain language implementation bugs currently prevent this on some platforms.
|
|||
|
</p>
|
|||
|
<p>
|
|||
|
Some methods may return non-zero values without issuing an exception. This occurs in
|
|||
|
situations that are not normally considered an error, but when some informational status
|
|||
|
is returned. For example, the <a class="xref" href="dbget.html" title="Db::get()">Db::get()</a> method returns
|
|||
|
<a href="../../programmer_reference/program_errorret.html#program_errorret.DB_NOTFOUND" class="olink">DB_NOTFOUND</a>
|
|||
|
when a requested key does not appear in the database.
|
|||
|
</p>
|
|||
|
<div class="sect1" lang="en" xml:lang="en">
|
|||
|
<div class="titlepage">
|
|||
|
<div>
|
|||
|
<div>
|
|||
|
<h2 class="title" style="clear: both"><a id="exceptionlist"></a>DB C++ Exceptions</h2>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<div class="navtable">
|
|||
|
<table border="1" width="80%">
|
|||
|
<thead>
|
|||
|
<tr>
|
|||
|
<th>DB C++ Exceptions</th>
|
|||
|
<th>Description</th>
|
|||
|
</tr>
|
|||
|
</thead>
|
|||
|
<tbody>
|
|||
|
<tr>
|
|||
|
<td>
|
|||
|
<a class="xref" href="dbdeadlock.html" title="DbDeadlockException">DbDeadlockException</a>
|
|||
|
</td>
|
|||
|
<td>Exception class for deadlocks</td>
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td>
|
|||
|
<a class="xref" href="dblocknotgranted.html" title="DbLockNotGrantedException">DbLockNotGrantedException</a>
|
|||
|
</td>
|
|||
|
<td>Exception class for lock request failures</td>
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td>
|
|||
|
<a class="xref" href="dbmemory.html" title="DbMemoryException">DbMemoryException</a>
|
|||
|
</td>
|
|||
|
<td>Exception class for insufficient memory</td>
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td>
|
|||
|
<a class="xref" href="dbrephandledead.html" title="DbRepHandleDeadException">DbRepHandleDeadException</a>
|
|||
|
</td>
|
|||
|
<td>Exception class for database and cursor handles that are invalidated in a replicated application. </td>
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td>
|
|||
|
<a class="xref" href="dbrunrecovery.html" title="DbRunRecoveryException">DbRunRecoveryException</a>
|
|||
|
</td>
|
|||
|
<td>Exception class for failures requiring recovery</td>
|
|||
|
</tr>
|
|||
|
</tbody>
|
|||
|
</table>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<div class="navfooter">
|
|||
|
<hr />
|
|||
|
<table width="100%" summary="Navigation footer">
|
|||
|
<tr>
|
|||
|
<td width="40%" align="left"><a accesskey="p" href="envversion.html">Prev</a> </td>
|
|||
|
<td width="20%" align="center"> </td>
|
|||
|
<td width="40%" align="right"> <a accesskey="n" href="dbdeadlock.html">Next</a></td>
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td width="40%" align="left" valign="top">DbEnv::version() </td>
|
|||
|
<td width="20%" align="center">
|
|||
|
<a accesskey="h" href="index.html">Home</a>
|
|||
|
</td>
|
|||
|
<td width="40%" align="right" valign="top"> DbDeadlockException</td>
|
|||
|
</tr>
|
|||
|
</table>
|
|||
|
</div>
|
|||
|
</body>
|
|||
|
</html>
|