errors.html   [plain text]


<!--$Id: errors.html,v 1.2 2004/03/30 01:22:58 jtownsen Exp $-->
<!--Copyright 1997-2003 by Sleepycat Software, Inc.-->
<!--All rights reserved.-->
<!--See the file LICENSE for redistribution information.-->
<html>
<head>
<title>Berkeley DB Reference Guide: Error returns</title>
<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit.">
<meta name="keywords" content="embedded,database,programmatic,toolkit,b+tree,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,Java,C,C++">
</head>
<body bgcolor=white>
<table width="100%"><tr valign=top>
<td><h3><dl><dt>Berkeley DB Reference Guide:<dd>Simple Tutorial</dl></h3></td>
<td align=right><a href="../simple_tut/handles.html"><img src="../../images/prev.gif" alt="Prev"></a><a href="../toc.html"><img src="../../images/ref.gif" alt="Ref"></a><a href="../simple_tut/open.html"><img src="../../images/next.gif" alt="Next"></a>
</td></tr></table>
<p>
<h3 align=center>Error returns</h3>
<p>The Berkeley DB interfaces always return a value of 0 on success.  If the
operation does not succeed for any reason, the return value will be
non-zero.</p>
<p>If a system error occurred (for example, Berkeley DB ran out of disk space,
or permission to access a file was denied, or an illegal argument was
specified to one of the interfaces), Berkeley DB returns an <b>errno</b>
value.  All of the possible values of <b>errno</b> are greater than
0.</p>
<p>If the operation didn't fail due to a system error, but wasn't
successful either, Berkeley DB returns a special error value.  For example,
if you tried to retrieve the data item associated with the key
<b>fruit</b>, and there was no such key/data pair in the database,
Berkeley DB would return <a href="../../ref/program/errorret.html#DB_NOTFOUND">DB_NOTFOUND</a>, a special error value that means
the requested key does not appear in the database.  All of the possible
special error values are less than 0.</p>
<p>Berkeley DB also offers programmatic support for displaying error return values.
First, the <a href="../../api_c/env_strerror.html">db_strerror</a> function returns a pointer to the error
message corresponding to any Berkeley DB error return, similar to the ANSI C
strerror function, but is able to handle both system error returns and
Berkeley DB-specific return values.</p>
<p>Second, there are two error functions, <a href="../../api_c/db_err.html">DB-&gt;err</a> and <a href="../../api_c/db_err.html">DB-&gt;errx</a>.
These functions work like the ANSI C printf function, taking a
printf-style format string and argument list, and optionally appending
the standard error string to a message constructed from the format
string and other arguments.</p>
<table width="100%"><tr><td><br></td><td align=right><a href="../simple_tut/handles.html"><img src="../../images/prev.gif" alt="Prev"></a><a href="../toc.html"><img src="../../images/ref.gif" alt="Ref"></a><a href="../simple_tut/open.html"><img src="../../images/next.gif" alt="Next"></a>
</td></tr></table>
<p><font size=1><a href="../../sleepycat/legal.html">Copyright (c) 1996-2003</a> <a href="http://www.sleepycat.com">Sleepycat Software, Inc.</a> - All rights reserved.</font>
</body>
</html>