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_ENV->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="env.html" title="Chapter��5.�� The DB_ENV Handle" /> 11 <link rel="prev" href="envevent_notify.html" title="DB_ENV->set_event_notify()" /> 12 <link rel="next" href="envset_errfile.html" title="DB_ENV->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_ENV->set_errcall()</th> 19 </tr> 20 <tr> 21 <td width="20%" align="left"><a accesskey="p" href="envevent_notify.html">Prev</a>��</td> 22 <th width="60%" align="center">Chapter��5.�� 23 The DB_ENV Handle 24 </th> 25 <td width="20%" align="right">��<a accesskey="n" href="envset_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="envset_errcall"></a>DB_ENV->set_errcall()</h2> 35 </div> 36 </div> 37 </div> 38 <pre class="programlisting">#include <db.h> 39 40void 41DB_ENV->set_errcall(DB_ENV *dbenv, void (*db_errcall_fcn) 42 (const DB_ENV *dbenv, const char *errpfx, const char *msg)); </pre> 43 <p> 44 When an error occurs in the Berkeley DB library, 45 <span> 46 a Berkeley DB error 47 </span> 48 49 or an error return value is returned by the interface. In some cases, 50 however, the <span class="bold"><strong>errno</strong></span> value may be 51 insufficient to completely describe the cause of the error, especially 52 during initial application debugging. 53 </p> 54 <p> 55 The <code class="methodname">DB_ENV->set_errcall()</code> and 56 <a class="xref" href="envset_errcall.html" title="DB_ENV->set_errcall()">DB_ENV->set_errcall()</a> methods 57 are used to enhance the mechanism for reporting error messages to the 58 application. In some cases, when an error occurs, Berkeley DB will 59 call <span class="bold"><strong>db_errcall_fcn</strong></span> with additional 60 error information. It is up to the <span class="bold"><strong>db_errcall_fcn</strong></span> function to display the error 61 message in an appropriate manner. 62 </p> 63 <p> 64 Setting <span class="bold"><strong>db_errcall_fcn</strong></span> to NULL 65 unconfigures the callback interface. 66 </p> 67 <p> 68 Alternatively, you can use the 69 70 71 <a class="xref" href="dbset_errfile.html" title="DB->set_errfile()">DB->set_errfile()</a> or 72 <a class="xref" href="envset_errfile.html" title="DB_ENV->set_errfile()">DB->set_errfile()</a> 73 methods to display the additional information via a C library <code class="literal">FILE *</code>. 74 75 </p> 76 <p> 77 This error-logging enhancement does not slow performance or 78 significantly increase application size, and may be run during normal 79 operation as well as during application debugging. 80 </p> 81 <p> 82 The <code class="methodname">DB_ENV->set_errcall()</code> method configures operations performed 83 using the specified <a class="link" href="env.html" title="Chapter��5.�� The DB_ENV Handle">DB_ENV</a> handle, not all 84 operations performed on the underlying database environment. 85 </p> 86 <p> 87 The <code class="methodname">DB_ENV->set_errcall()</code> method may be called at any time during the 88 life of the application. 89 </p> 90 <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"> 91 <h3 class="title">Note</h3> 92 <p> 93 Berkeley DB is not re-entrant. Callback functions should not attempt to make library 94 calls (for example, to release locks or close open handles). Re-entering Berkeley DB is 95 not guaranteed to work correctly, and the results are undefined. 96 </p> 97 </div> 98 <div class="sect2" lang="en" xml:lang="en"> 99 <div class="titlepage"> 100 <div> 101 <div> 102 <h3 class="title"><a id="id1668499"></a>Parameters</h3> 103 </div> 104 </div> 105 </div> 106 <div class="sect3" lang="en" xml:lang="en"> 107 <div class="titlepage"> 108 <div> 109 <div> 110 <h4 class="title"><a id="id1667909"></a>db_errcall_fcn</h4> 111 </div> 112 </div> 113 </div> 114 <p> 115 The <span class="bold"><strong>db_errcall_fcn</strong></span> parameter is the 116 application-specified error reporting function. The function takes 117 three parameters: 118 </p> 119 <div class="itemizedlist"> 120 <ul type="disc"> 121 <li> 122 <p> 123 <code class="literal">dbenv</code> 124 </p> 125 <p> 126 The <span class="bold"><strong>dbenv</strong></span> parameter is the enclosing 127 database environment. 128 </p> 129 </li> 130 <li> 131 <p> 132 <code class="literal">errpfx</code> 133 </p> 134 <p> 135 The <span class="bold"><strong>errpfx</strong></span> parameter is the prefix 136 string (as previously set by 137 <a class="xref" href="dbset_errpfx.html" title="DB->set_errpfx()">DB->set_errpfx()</a> or 138 <a class="xref" href="envset_errpfx.html" title="DB_ENV->set_errpfx()">DB_ENV->set_errpfx()</a>). 139 </p> 140 </li> 141 <li> 142 <p> 143 <code class="literal">msg</code> 144 </p> 145 <p> 146 The <span class="bold"><strong>msg</strong></span> parameter is the error 147 message string. 148 </p> 149 </li> 150 </ul> 151 </div> 152 </div> 153 </div> 154 <div class="sect2" lang="en" xml:lang="en"> 155 <div class="titlepage"> 156 <div> 157 <div> 158 <h3 class="title"><a id="id1668816"></a>Class</h3> 159 </div> 160 </div> 161 </div> 162 <p> 163 <a class="link" href="env.html" title="Chapter��5.�� The DB_ENV Handle">DB_ENV</a> 164 </p> 165 </div> 166 <div class="sect2" lang="en" xml:lang="en"> 167 <div class="titlepage"> 168 <div> 169 <div> 170 <h3 class="title"><a id="id1667960"></a>See Also</h3> 171 </div> 172 </div> 173 </div> 174 <p> 175 <a class="xref" href="env.html#envlist" title="Database Environments and Related Methods">Database Environments and Related Methods</a> 176 </p> 177 </div> 178 </div> 179 <div class="navfooter"> 180 <hr /> 181 <table width="100%" summary="Navigation footer"> 182 <tr> 183 <td width="40%" align="left"><a accesskey="p" href="envevent_notify.html">Prev</a>��</td> 184 <td width="20%" align="center"> 185 <a accesskey="u" href="env.html">Up</a> 186 </td> 187 <td width="40%" align="right">��<a accesskey="n" href="envset_errfile.html">Next</a></td> 188 </tr> 189 <tr> 190 <td width="40%" align="left" valign="top">DB_ENV->set_event_notify()��</td> 191 <td width="20%" align="center"> 192 <a accesskey="h" href="index.html">Home</a> 193 </td> 194 <td width="40%" align="right" valign="top">��DB_ENV->set_errfile()</td> 195 </tr> 196 </table> 197 </div> 198 </body> 199</html> 200