1
<!--$Id: errors.so,v 10.20 2001/03/01 15:58:13 bostic Exp $-->
2
<!--Copyright 1997-2001 by Sleepycat Software, Inc.-->
3
<!--All rights reserved.-->
6
<title>Berkeley DB Reference Guide: Error returns</title>
7
<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit.">
8
<meta name="keywords" content="embedded,database,programmatic,toolkit,b+tree,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,java,C,C++">
11
<table width="100%"><tr valign=top>
12
<td><h3><dl><dt>Berkeley DB Reference Guide:<dd>Simple Tutorial</dl></h3></td>
13
<td align=right><a href="../../ref/simple_tut/handles.html"><img src="../../images/prev.gif" alt="Prev"></a><a href="../../reftoc.html"><img src="../../images/ref.gif" alt="Ref"></a><a href="../../ref/simple_tut/open.html"><img src="../../images/next.gif" alt="Next"></a>
16
<h1 align=center>Error returns</h1>
17
<p>The Berkeley DB interfaces always return a value of 0 on success. If the
18
operation does not succeed for any reason, the return value will be
20
<p>If a system error occurred (for example, Berkeley DB ran out of disk space,
21
or permission to access a file was denied, or an illegal argument was
22
specified to one of the interfaces), Berkeley DB returns an <b>errno</b>
23
value. All of the possible values of <b>errno</b> are greater than
25
<p>If the operation didn't fail due to a system error, but wasn't
26
successful either, Berkeley DB returns a special error value. For example,
27
if you tried to retrieve the data item associated with the key
28
<b>fruit</b>, and there was no such key/data pair in the database,
29
Berkeley DB would return <a href="../../ref/program/errorret.html#DB_NOTFOUND">DB_NOTFOUND</a>, a special error value that means
30
the requested key does not appear in the database. All of the possible
31
special error values are less than 0.
32
<p>Berkeley DB also offers programmatic support for displaying error return values.
33
First, the <a href="../../api_c/env_strerror.html">db_strerror</a> interface returns a pointer to the error
34
message corresponding to any Berkeley DB error return, similar to the ANSI C
35
strerror interface, but is able to handle both system error returns and
36
Berkeley DB-specific return values.
37
<p>Second, there are two error functions, <a href="../../api_c/db_err.html">DB->err</a> and <a href="../../api_c/db_err.html">DB->errx</a>.
38
These functions work like the ANSI C printf interface, taking a
39
printf-style format string and argument list, and optionally appending
40
the standard error string to a message constructed from the format string
42
<table width="100%"><tr><td><br></td><td align=right><a href="../../ref/simple_tut/handles.html"><img src="../../images/prev.gif" alt="Prev"></a><a href="../../reftoc.html"><img src="../../images/ref.gif" alt="Ref"></a><a href="../../ref/simple_tut/open.html"><img src="../../images/next.gif" alt="Next"></a>
44
<p><font size=1><a href="http://www.sleepycat.com">Copyright Sleepycat Software</a></font>