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_error_stream()</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_errfile.html" title="Db::set_errfile()" /> 12 <link rel="next" href="dbset_errpfx.html" title="Db::set_errpfx()" /> 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_error_stream()</th> 19 </tr> 20 <tr> 21 <td width="20%" align="left"><a accesskey="p" href="dbset_errfile.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_errpfx.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_error_stream"></a>Db::set_error_stream()</h2> 35 </div> 36 </div> 37 </div> 38 <pre class="programlisting">#include <db_cxx.h> 39 40void Db::set_error_stream(class ostream*); </pre> 41 <p> 42 When an error occurs in the Berkeley DB library, an exception 43 is thrown or an <span class="bold"><strong>errno</strong></span> value 44 is returned by the interface. In some cases, however, the 45 <span class="bold"><strong>errno</strong></span> value may be 46 insufficient to completely describe the cause of the error, 47 especially during initial application debugging. 48 </p> 49 <p> 50 The <a class="xref" href="envset_error_stream.html" title="DbEnv::set_error_stream()">DbEnv::set_error_stream()</a> 51 and <code class="methodname">Db::set_error_stream()</code> methods are used 52 to enhance the mechanism for reporting error messages to the 53 application by setting the C++ ostream used for displaying 54 additional Berkeley DB error messages. In some cases, when an 55 error occurs, Berkeley DB will output an additional error message 56 to the specified stream. 57 </p> 58 <p> 59 The error message will consist of the prefix string and a colon 60 ("<span class="bold"><strong>:</strong></span>") (if a prefix string was 61 previously specified using 62 <a class="xref" href="dbset_errpfx.html" title="Db::set_errpfx()">Db::set_errpfx()</a>, 63 an error string, and a trailing <newline> character. 64 </p> 65 <p> 66 Setting <span class="bold"><strong>stream</strong></span> to NULL unconfigures the interface. 67 </p> 68 <p> 69 Alternatively, you can use the 70 <a class="xref" href="envset_errfile.html" title="DbEnv::set_errfile()">DbEnv::set_errfile()</a> or 71 <a class="xref" href="dbset_errfile.html" title="Db::set_errfile()">Db::set_errfile()</a> methods 72 to display the additional information via a C Library <code class="literal">FILE *</code>, 73 or the <a class="xref" href="envset_errcall.html" title="DbEnv::set_errcall()">DbEnv::set_errcall()</a> 74 and <a class="xref" href="dbset_errcall.html" title="Db::set_errcall()">Db::set_errcall()</a> 75 methods to capture the additional error information in a way that does not use either 76 output streams or C Library <code class="literal">FILE *</code>'s. 77 You should not mix these approaches. 78 </p> 79 <p> 80 This error-logging enhancement does not slow performance or significantly increase 81 application size, and may be run during normal operation as well as during application 82 debugging. 83 </p> 84 <p> 85 For <a class="link" href="db.html" title="Chapter 2. The Db Handle">Db</a> handles opened inside of Berkeley DB 86 environments, calling the <code class="methodname">Db::set_error_stream()</code> method 87 affects the entire environment and is equivalent to calling the 88 <a class="xref" href="envset_error_stream.html" title="DbEnv::set_error_stream()">DbEnv::set_error_stream()</a> method. 89 </p> 90 <p> 91 The <code class="methodname">Db::set_error_stream()</code> method may be called at any time during the 92 life of the application. 93 </p> 94 <div class="sect2" lang="en" xml:lang="en"> 95 <div class="titlepage"> 96 <div> 97 <div> 98 <h3 class="title"><a id="id1646554"></a>Parameters</h3> 99 </div> 100 </div> 101 </div> 102 <div class="sect3" lang="en" xml:lang="en"> 103 <div class="titlepage"> 104 <div> 105 <div> 106 <h4 class="title"><a id="id1646593"></a>stream</h4> 107 </div> 108 </div> 109 </div> 110 <p> 111 The <span class="bold"><strong>stream</strong></span> parameter is the 112 application-specified output stream to be used for additional error 113 information. 114 </p> 115 </div> 116 </div> 117 <div class="sect2" lang="en" xml:lang="en"> 118 <div class="titlepage"> 119 <div> 120 <div> 121 <h3 class="title"><a id="id1646737"></a>Class</h3> 122 </div> 123 </div> 124 </div> 125 <p> 126 <a class="link" href="db.html" title="Chapter 2. The Db Handle">Db</a> 127 </p> 128 </div> 129 <div class="sect2" lang="en" xml:lang="en"> 130 <div class="titlepage"> 131 <div> 132 <div> 133 <h3 class="title"><a id="id1646672"></a>See Also</h3> 134 </div> 135 </div> 136 </div> 137 <p> 138 <a class="xref" href="db.html#dblist" title="Database and Related Methods">Database and Related Methods</a> 139 </p> 140 </div> 141 </div> 142 <div class="navfooter"> 143 <hr /> 144 <table width="100%" summary="Navigation footer"> 145 <tr> 146 <td width="40%" align="left"><a accesskey="p" href="dbset_errfile.html">Prev</a> </td> 147 <td width="20%" align="center"> 148 <a accesskey="u" href="db.html">Up</a> 149 </td> 150 <td width="40%" align="right"> <a accesskey="n" href="dbset_errpfx.html">Next</a></td> 151 </tr> 152 <tr> 153 <td width="40%" align="left" valign="top">Db::set_errfile() </td> 154 <td width="20%" align="center"> 155 <a accesskey="h" href="index.html">Home</a> 156 </td> 157 <td width="40%" align="right" valign="top"> Db::set_errpfx()</td> 158 </tr> 159 </table> 160 </div> 161 </body> 162</html> 163