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>Db::set_errcall()</title> 7 <link rel="stylesheet" href="apiReference.css" type="text/css" /> 8 <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" /> 9 <link rel="start" href="index.html" title="Berkeley DB C++ API Reference" /> 10 <link rel="up" href="db.html" title="Chapter 2. The Db Handle" /> 11 <link rel="prev" href="dbset_encrypt.html" title="Db::set_encrypt()" /> 12 <link rel="next" href="dbset_errfile.html" title="Db::set_errfile()" /> 13 </head> 14 <body> 15 <div class="navheader"> 16 <table width="100%" summary="Navigation header"> 17 <tr> 18 <th colspan="3" align="center">Db::set_errcall()</th> 19 </tr> 20 <tr> 21 <td width="20%" align="left"><a accesskey="p" href="dbset_encrypt.html">Prev</a> </td> 22 <th width="60%" align="center">Chapter 2. 23 The Db Handle 24 </th> 25 <td width="20%" align="right"> <a accesskey="n" href="dbset_errfile.html">Next</a></td> 26 </tr> 27 </table> 28 <hr /> 29 </div> 30 <div class="sect1" lang="en" xml:lang="en"> 31 <div class="titlepage"> 32 <div> 33 <div> 34 <h2 class="title" style="clear: both"><a id="dbset_errcall"></a>Db::set_errcall()</h2> 35 </div> 36 </div> 37 </div> 38 <pre class="programlisting">#include <db_cxx.h> 39 40void Db::set_errcall(void (*db_errcall_fcn) 41 (const DbEnv *dbenv, const char *errpfx, const char *msg));</pre> 42 <p> 43 When an error occurs in the Berkeley DB library, 44 45 <span> 46 an exception is thrown 47 </span> 48 or an error return value is returned by the interface. In some cases, 49 however, the <span class="bold"><strong>errno</strong></span> value may be 50 insufficient to completely describe the cause of the error, especially 51 during initial application debugging. 52 </p> 53 <p> 54 The <a class="xref" href="envset_errcall.html" title="DbEnv::set_errcall()">DbEnv::set_errcall()</a> and 55 <code class="methodname">Db::set_errcall()</code> methods are used to enhance the mechanism for 56 reporting error messages to the application. In some cases, when an 57 error occurs, Berkeley DB will call <span class="bold"><strong>db_errcall_fcn()</strong></span> 58 with additional error information. It is up to the 59 <span class="bold"><strong>db_errcall_fcn()</strong></span> function to display the error 60 message in an appropriate manner. 61 </p> 62 <p> 63 Setting <span class="bold"><strong>db_errcall_fcn</strong></span> to NULL 64 unconfigures the callback interface. 65 </p> 66 <p> 67 Alternatively, you can use the 68 <span> 69 <a class="xref" href="envset_error_stream.html" title="DbEnv::set_error_stream()">DbEnv::set_error_stream()</a> 70 and 71 <a class="xref" href="dbset_error_stream.html" title="Db::set_error_stream()">Db::set_error_stream()</a> 72 methods to display the additional information via an output stream, or the 73 </span> 74 75 <a class="xref" href="dbset_errfile.html" title="Db::set_errfile()">Db::set_errfile()</a> or 76 <a class="xref" href="envset_errfile.html" title="DbEnv::set_errfile()">Db::set_errfile()</a> 77 methods to display the additional information via a C library <code class="literal">FILE *</code>. 78 <span>You should not mix these approaches.</span> 79 </p> 80 <p> 81 This error-logging enhancement does not slow performance or 82 significantly increase application size, and may be run during normal 83 operation as well as during application debugging. 84 </p> 85 <p> 86 For <a class="link" href="db.html" title="Chapter 2. The Db Handle">Db</a> handles opened 87 inside of Berkeley DB environments, calling the 88 <code class="methodname">Db::set_errcall()</code> 89 method affects the entire environment and is equivalent to calling the 90 <a class="xref" href="envset_errcall.html" title="DbEnv::set_errcall()">DbEnv::set_errcall()</a> 91 method. 92 </p> 93 <p> 94 When used on a database that was <span class="emphasis"><em>not</em></span> opened in 95 an environment, the <code class="methodname">Db::set_errcall()</code> 96 method configures operations performed using the specified 97 <a class="link" href="db.html" title="Chapter 2. The Db Handle">Db</a> handle, not all operations 98 performed on the underlying database. 99 </p> 100 <p> 101 The <code class="methodname">Db::set_errcall()</code> method may be called at any time during the 102 life of the application. 103 </p> 104 <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"> 105 <h3 class="title">Note</h3> 106 <p> 107 Berkeley DB is not re-entrant. Callback functions should not attempt to make library 108 calls (for example, to release locks or close open handles). Re-entering Berkeley DB is 109 not guaranteed to work correctly, and the results are undefined. 110 </p> 111 </div> 112 <div class="sect2" lang="en" xml:lang="en"> 113 <div class="titlepage"> 114 <div> 115 <div> 116 <h3 class="title"><a id="id1645914"></a>Parameters</h3> 117 </div> 118 </div> 119 </div> 120 <div class="sect3" lang="en" xml:lang="en"> 121 <div class="titlepage"> 122 <div> 123 <div> 124 <h4 class="title"><a id="id1645826"></a>db_errcall_fcn</h4> 125 </div> 126 </div> 127 </div> 128 <p> 129 The <span class="bold"><strong>db_errcall_fcn</strong></span> parameter is the 130 application-specified error reporting function. The function takes 131 three parameters: 132 </p> 133 <div class="itemizedlist"> 134 <ul type="disc"> 135 <li> 136 <p> 137 <code class="literal">dbenv</code> 138 </p> 139 <p> 140 The <span class="bold"><strong>dbenv</strong></span> parameter is the enclosing 141 database environment. 142 </p> 143 </li> 144 <li> 145 <p> 146 <code class="literal">errpfx</code> 147 </p> 148 <p> 149 The <span class="bold"><strong>errpfx</strong></span> parameter is the prefix 150 string (as previously set by 151 <a class="xref" href="dbset_errpfx.html" title="Db::set_errpfx()">Db::set_errpfx()</a> or 152 <a class="xref" href="envset_errpfx.html" title="DbEnv::set_errpfx()">DbEnv::set_errpfx()</a> ). 153 </p> 154 </li> 155 <li> 156 <p> 157 <code class="literal">msg</code> 158 </p> 159 <p> 160 The <span class="bold"><strong>msg</strong></span> parameter is the error 161 message string. 162 </p> 163 </li> 164 </ul> 165 </div> 166 </div> 167 </div> 168 <div class="sect2" lang="en" xml:lang="en"> 169 <div class="titlepage"> 170 <div> 171 <div> 172 <h3 class="title"><a id="id1646064"></a>Class</h3> 173 </div> 174 </div> 175 </div> 176 <p> 177 <a class="link" href="db.html" title="Chapter 2. The Db Handle">Db</a> 178 </p> 179 </div> 180 <div class="sect2" lang="en" xml:lang="en"> 181 <div class="titlepage"> 182 <div> 183 <div> 184 <h3 class="title"><a id="id1645990"></a>See Also</h3> 185 </div> 186 </div> 187 </div> 188 <p> 189 <a class="xref" href="db.html#dblist" title="Database and Related Methods">Database and Related Methods</a> 190 </p> 191 </div> 192 </div> 193 <div class="navfooter"> 194 <hr /> 195 <table width="100%" summary="Navigation footer"> 196 <tr> 197 <td width="40%" align="left"><a accesskey="p" href="dbset_encrypt.html">Prev</a> </td> 198 <td width="20%" align="center"> 199 <a accesskey="u" href="db.html">Up</a> 200 </td> 201 <td width="40%" align="right"> <a accesskey="n" href="dbset_errfile.html">Next</a></td> 202 </tr> 203 <tr> 204 <td width="40%" align="left" valign="top">Db::set_encrypt() </td> 205 <td width="20%" align="center"> 206 <a accesskey="h" href="index.html">Home</a> 207 </td> 208 <td width="40%" align="right" valign="top"> Db::set_errfile()</td> 209 </tr> 210 </table> 211 </div> 212 </body> 213</html> 214