1<!--$Id: except_class.so,v 10.38 2004/09/28 15:04:19 bostic Exp $--> 2<!--Copyright (c) 1997,2008 Oracle. All rights reserved.--> 3<!--See the file LICENSE for redistribution information.--> 4<html> 5<head> 6<title>Berkeley DB: DbException</title> 7<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit."> 8<meta name="keywords" content="embedded,database,programmatic,toolkit,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,Java,C,C++"> 9</head> 10<body bgcolor=white> 11<table width="100%"><tr valign=top> 12<td> 13<b>DbException</b> 14</td> 15<td align=right> 16<a href="../api_cxx/api_core.html"><img src="../images/api.gif" alt="API"></a> 17<a href="../ref/toc.html"><img src="../images/ref.gif" alt="Ref"></a></td> 18</tr></table> 19<hr size=1 noshade> 20<tt> 21<b><pre> 22#include <db_cxx.h> 23<p> 24class DbException { 25public: 26 int get_errno() const; 27 virtual const char *what() const; 28 DbEnv *get_env() const; 29}; 30</pre></b> 31<hr size=1 noshade> 32<b>Description: DbException</b> 33<p>This information describes the DbException class and how it is 34used by the various Berkeley DB classes.</p> 35<p>Most methods in the Berkeley DB classes return an int, but also throw an 36exception. This allows for two different error behaviors. By default, 37the Berkeley DB C++ API is configured to throw an exception whenever a serious 38error occurs. This generally allows for cleaner logic for transaction 39processing because a try block can surround a single transaction. 40Alternatively, Berkeley DB can be configured to not throw exceptions, and 41instead have the individual function return an error code, by setting 42the <a href="../api_cxx/env_class.html#DB_CXX_NO_EXCEPTIONS">DB_CXX_NO_EXCEPTIONS</a> for the <a href="../api_cxx/db_class.html">Db</a> and <a href="../api_cxx/env_class.html">DbEnv</a> 43constructors.</p> 44<p>A DbException object contains an informational string, an errno, and a 45reference to the environment from which the exception was thrown. The 46errno can be obtained by using DbException::get_errno, and can be 47used, in standard cases, to determine the type of the exception. The 48informational string can be obtained by using DbException::what. And, 49the environment can be obtained using DbException::get_env.</p> 50<p>We expect in the future that this class will inherit from the standard 51class exception, but certain language implementation bugs currently 52prevent this on some platforms.</p> 53<p>Some methods may return non-zero values without issuing an exception. 54This occurs in situations that are not normally considered an error, but 55when some informational status is returned. For example, 56<a href="../api_cxx/db_get.html">Db::get</a> returns <a href="../ref/program/errorret.html#DB_NOTFOUND">DB_NOTFOUND</a> when a requested key does 57not appear in the database.</p> 58</tt> 59<table width="100%"><tr><td><br></td><td align=right> 60<a href="../api_cxx/api_core.html"><img src="../images/api.gif" alt="API"></a><a href="../ref/toc.html"><img src="../images/ref.gif" alt="Ref"></a> 61</td></tr></table> 62<p><font size=1>Copyright (c) 1996,2008 Oracle. All rights reserved.</font> 63</body> 64</html> 65