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