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_errfile()</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_errcall.html" title="Db::set_errcall()" /> 12 <link rel="next" href="dbset_error_stream.html" title="Db::set_error_stream()" /> 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_errfile()</th> 19 </tr> 20 <tr> 21 <td width="20%" align="left"><a accesskey="p" href="dbset_errcall.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_error_stream.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_errfile"></a>Db::set_errfile()</h2> 35 </div> 36 </div> 37 </div> 38 <pre class="programlisting">#include <db_cxx.h> 39 40void Db::set_errfile(FILE *errfile); </pre> 41 <p> 42 When an error occurs in the Berkeley DB library, 43 44 <span> 45 an exception is thrown 46 </span> 47 or an error return value is returned by the interface. In some cases, 48 however, the <span class="bold"><strong>errno</strong></span> value may be 49 insufficient to completely describe the cause of the error, especially 50 during initial application debugging. 51 </p> 52 <p> 53 The <a class="xref" href="envset_errfile.html" title="DbEnv::set_errfile()">DbEnv::set_errfile()</a> and 54 <code class="methodname">Db::set_errfile()</code> methods are used to enhance the mechanism for 55 reporting error messages to the application by setting a C library 56 FILE * to be used for displaying additional Berkeley DB error 57 messages. In some cases, when an error occurs, Berkeley DB will 58 output an additional error message to the specified file reference. 59 </p> 60 <p> 61 Alternatively, you can use the 62 <span> 63 <a class="xref" href="envset_error_stream.html" title="DbEnv::set_error_stream()">DbEnv::set_error_stream()</a> 64 and 65 <a class="xref" href="dbset_error_stream.html" title="Db::set_error_stream()">Db::set_error_stream()</a> 66 methods to display the additional messages via an output stream, or the 67 </span> 68 69 <a class="xref" href="envset_errcall.html" title="DbEnv::set_errcall()">DbEnv::set_errcall()</a> or 70 <a class="xref" href="dbset_errcall.html" title="Db::set_errcall()">Db::set_errcall()</a> 71 methods to capture the additional error information in a way that does 72 not use C library FILE *'s. 73 <span>You should not mix these approaches.</span> 74 </p> 75 <p> 76 The error message will consist of the prefix string and a colon 77 ("<span class="bold"><strong>:</strong></span>") (if a prefix string was 78 previously specified using 79 <a class="xref" href="dbset_errpfx.html" title="Db::set_errpfx()">Db::set_errpfx()</a> or 80 <a class="xref" href="envset_errpfx.html" title="DbEnv::set_errpfx()">DbEnv::set_errpfx()</a> ), an 81 error string, and a trailing <newline> character. 82 </p> 83 <p> 84 The default configuration when applications first create 85 <a class="link" href="db.html" title="Chapter 2. The Db Handle">Db</a> or 86 <a class="link" href="env.html" title="Chapter 5. The DbEnv Handle">DbEnv</a> handles is as if the 87 <a class="xref" href="envset_errfile.html" title="DbEnv::set_errfile()">DbEnv::set_errfile()</a> or 88 <code class="methodname">Db::set_errfile()</code> methods were called with the standard error output 89 (stderr) specified as the FILE * argument. Applications wanting no 90 output at all can turn off this default configuration by calling the 91 <a class="xref" href="envset_errfile.html" title="DbEnv::set_errfile()">DbEnv::set_errfile()</a> or 92 <code class="methodname">Db::set_errfile()</code> methods with NULL as the FILE * argument. 93 Additionally, explicitly configuring the error output channel using 94 any of the following methods will also turn off this default output for the application: 95 </p> 96 <div class="itemizedlist"> 97 <ul type="disc"> 98 <li> 99 <p> 100 <code class="methodname">Db::set_errfile()</code> 101 </p> 102 </li> 103 <li> 104 <p> 105 <a class="xref" href="envset_errfile.html" title="DbEnv::set_errfile()">DbEnv::set_errfile()</a> 106 </p> 107 </li> 108 <li> 109 <p> 110 <a class="xref" href="envset_errcall.html" title="DbEnv::set_errcall()">DbEnv::set_errcall()</a> 111 </p> 112 </li> 113 <li> 114 <p> 115 <a class="xref" href="dbset_errcall.html" title="Db::set_errcall()">Db::set_errcall()</a> 116 </p> 117 </li> 118 <li> 119 <p> 120 <a class="xref" href="envset_error_stream.html" title="DbEnv::set_error_stream()">DbEnv::set_error_stream()</a> 121 </p> 122 </li> 123 <li> 124 <p> 125 <a class="xref" href="dbset_error_stream.html" title="Db::set_error_stream()">Db::set_error_stream()</a> 126 </p> 127 </li> 128 </ul> 129 </div> 130 <p> 131 This error logging enhancement does not slow performance or 132 significantly increase application size, and may be run during normal 133 operation as well as during application debugging. 134 </p> 135 <p> 136 For <a class="link" href="db.html" title="Chapter 2. The Db Handle">Db</a> handles opened 137 inside of Berkeley DB environments, calling the 138 <code class="methodname">Db::set_errfile()</code> 139 method affects the entire environment and is equivalent to calling the 140 <a class="xref" href="envset_errfile.html" title="DbEnv::set_errfile()">DbEnv::set_errfile()</a> 141 method. 142 </p> 143 <p> 144 When used on a database that was <span class="emphasis"><em>not</em></span> opened in 145 an environment, the <code class="methodname">Db::set_errfile()</code> 146 method configures operations performed using the specified 147 <a class="link" href="db.html" title="Chapter 2. The Db Handle">Db</a> handle, not all operations 148 performed on the underlying database. 149 </p> 150 <p> 151 The <code class="methodname">Db::set_errfile()</code> method may be called at any time during the 152 life of the application. 153 </p> 154 <div class="sect2" lang="en" xml:lang="en"> 155 <div class="titlepage"> 156 <div> 157 <div> 158 <h3 class="title"><a id="id1646432"></a>Parameters</h3> 159 </div> 160 </div> 161 </div> 162 <div class="sect3" lang="en" xml:lang="en"> 163 <div class="titlepage"> 164 <div> 165 <div> 166 <h4 class="title"><a id="id1646161"></a>errfile</h4> 167 </div> 168 </div> 169 </div> 170 <p> 171 The <span class="bold"><strong>errfile</strong></span> parameter is a C library 172 <code class="literal">FILE *</code> to be used for displaying additional Berkeley DB error 173 information. 174 </p> 175 </div> 176 </div> 177 <div class="sect2" lang="en" xml:lang="en"> 178 <div class="titlepage"> 179 <div> 180 <div> 181 <h3 class="title"><a id="id1646512"></a>Class</h3> 182 </div> 183 </div> 184 </div> 185 <p> 186 <a class="link" href="db.html" title="Chapter 2. The Db Handle">Db</a> 187 </p> 188 </div> 189 <div class="sect2" lang="en" xml:lang="en"> 190 <div class="titlepage"> 191 <div> 192 <div> 193 <h3 class="title"><a id="id1646498"></a>See Also</h3> 194 </div> 195 </div> 196 </div> 197 <p> 198 <a class="xref" href="db.html#dblist" title="Database and Related Methods">Database and Related Methods</a> 199 </p> 200 </div> 201 </div> 202 <div class="navfooter"> 203 <hr /> 204 <table width="100%" summary="Navigation footer"> 205 <tr> 206 <td width="40%" align="left"><a accesskey="p" href="dbset_errcall.html">Prev</a> </td> 207 <td width="20%" align="center"> 208 <a accesskey="u" href="db.html">Up</a> 209 </td> 210 <td width="40%" align="right"> <a accesskey="n" href="dbset_error_stream.html">Next</a></td> 211 </tr> 212 <tr> 213 <td width="40%" align="left" valign="top">Db::set_errcall() </td> 214 <td width="20%" align="center"> 215 <a accesskey="h" href="index.html">Home</a> 216 </td> 217 <td width="40%" align="right" valign="top"> Db::set_error_stream()</td> 218 </tr> 219 </table> 220 </div> 221 </body> 222</html> 223