<divclass="RenoIncludeDIV"><h2>Logging of boost::exception Objects</h2>
<p>Class <tt>boost::<spanclass="RenoLink"><ahref="exception.html">exception</a></span></tt> provides a virtual member function <tt><spanclass="RenoLink"><ahref="exception_what.html">what</a></span>()</tt>, with a signature identical to the familiar <tt>std::exception::what()</tt> function. The default implementation returns a string value that is not presentable as a friendly user message, but because it is generated automatically, it is useful for debugging or logging purposes. Here is an example:</p>
<p>The <tt><spanclass="RenoLink"><ahref="exception_what.html">what</a></span>()</tt> member function iterates over all data objects stored in the <tt>boost::<spanclass="RenoLink"><ahref="exception.html">exception</a></span></tt> through <tt><spanclass="RenoLink"><ahref="operator_shl_exception.html">operator<<</a></span>()</tt>. The returned string is constructed by converting each data object to string and then concatenating these strings together.</p>
<p>When the <tt><spanclass="RenoLink"><ahref="error_info.html">error_info</a></span><Tag,T></tt> template is instantiated, the system attempts overload resolution for an unqualified call to <tt>to_string(x)</tt>, where <tt>x</tt> is of type <tt>T</tt>. If this is successful, the <tt>to_string()</tt> overload is used to convert objects of type <tt>T</tt> to string.</p>
<p>Otherwise, the system attempts overload resolution for <tt>s << x</tt>, where <tt>s</tt> is a <tt>std::ostringstream</tt> and <tt>x</tt> is of type <tt>T</tt>. If this is successful, the <tt>operator<<</tt> overload is used to convert objects of type <tt>T</tt> to string.</p>
<p>Otherwise the system is unable to convert objects of type <tt>T</tt> to string, and an unspecified stub string value is used without issuing a compile error.</p>