1<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3<html xmlns="http://www.w3.org/1999/xhtml">
4  <head>
5    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6    <title>Error Returns</title>
7    <link rel="stylesheet" href="gettingStarted.css" type="text/css" />
8    <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" />
9    <link rel="start" href="index.html" title="Getting Started with Berkeley DB" />
10    <link rel="up" href="introduction.html" title="Chapter��1.��Introduction to Berkeley DB" />
11    <link rel="prev" href="environments.html" title="Environments" />
12    <link rel="next" href="gettingit.html" title="Getting and Using DB" />
13  </head>
14  <body>
15    <div class="navheader">
16      <table width="100%" summary="Navigation header">
17        <tr>
18          <th colspan="3" align="center">Error Returns</th>
19        </tr>
20        <tr>
21          <td width="20%" align="left"><a accesskey="p" href="environments.html">Prev</a>��</td>
22          <th width="60%" align="center">Chapter��1.��Introduction to Berkeley DB </th>
23          <td width="20%" align="right">��<a accesskey="n" href="gettingit.html">Next</a></td>
24        </tr>
25      </table>
26      <hr />
27    </div>
28    <div class="sect1" lang="en" xml:lang="en">
29      <div class="titlepage">
30        <div>
31          <div>
32            <h2 class="title" style="clear: both"><a id="returns"></a>Error Returns</h2>
33          </div>
34        </div>
35      </div>
36      <p>
37        Before continuing, it is useful to spend a few moments on error returns
38        in DB.
39    </p>
40      <p>
41        
42        <span>The</span>
43        DB interfaces always return a value of 0 on success. If the
44        operation does not succeed for any reason, the return value will be
45        non-zero.
46    </p>
47      <p>
48        If a system error occurred (for example, DB ran out of disk
49        space, or permission to access a file was denied, or an illegal argument
50        was specified to one of the interfaces), DB returns an
51        <code class="literal">errno</code>
52        value. All of the possible values of <code class="literal">errno</code> are greater than 0.
53    </p>
54      <p>
55        If the operation did not fail due to a system error, but was not
56        successful either, DB returns a special error value. For
57        example, if you tried to retrieve data from the database and the
58        record for which you are searching does not exist, DB would return
59        <code class="literal">DB_NOTFOUND</code>, a special error value that means the requested
60        key does not appear in the database. All of the possible special error
61        values are less than 0.
62    </p>
63      <p>
64        DB also offers programmatic support for displaying error return
65        values. First, the <code class="function">db_strerror</code> function returns 
66        a pointer to the error
67        message corresponding to any DB error return, similar to the
68        ANSI C <code class="function">strerror</code> function, but is able to handle 
69        both system error returns and DB-specific return values.
70    </p>
71      <p>
72       Second, there are two error functions, 
73        <code class="methodname">DB-&gt;err</code> and <code class="methodname">DB-&gt;errx</code>. 
74       These functions work like the ANSI C <code class="function">printf</code> function, 
75       taking a printf-style format string and argument list, and optionally 
76       appending the standard error string to a message constructed from 
77       the format string and other arguments.
78    </p>
79    </div>
80    <div class="navfooter">
81      <hr />
82      <table width="100%" summary="Navigation footer">
83        <tr>
84          <td width="40%" align="left"><a accesskey="p" href="environments.html">Prev</a>��</td>
85          <td width="20%" align="center">
86            <a accesskey="u" href="introduction.html">Up</a>
87          </td>
88          <td width="40%" align="right">��<a accesskey="n" href="gettingit.html">Next</a></td>
89        </tr>
90        <tr>
91          <td width="40%" align="left" valign="top">Environments��</td>
92          <td width="20%" align="center">
93            <a accesskey="h" href="index.html">Home</a>
94          </td>
95          <td width="40%" align="right" valign="top">��Getting and Using DB </td>
96        </tr>
97      </table>
98    </div>
99  </body>
100</html>
101