1<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' 2'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'> 3<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'> 4<head> 5 <meta http-equiv='Content-Type' content='text/html; charset=utf-8'/> 6 <title>diagnostic information</title> 7 <link href='reno.css' type='text/css' rel='stylesheet'/> 8</head> 9<body> 10<div class="body-0"> 11<div class="body-1"> 12<div class="body-2"> 13<div> 14<div id="boost_logo"> 15<a href="http://www.boost.org"><img style="border:0" src="../../../boost.png" alt="Boost" width="277" height="86"/></a> 16</div> 17<h1>Boost Exception</h1> 18</div> 19<!-- Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc. --> 20<!-- Distributed under the Boost Software License, Version 1.0. (See accompanying --> 21<!-- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) --> 22<div class="RenoIncludeDIV"><div class="RenoAutoDIV"><h2>Diagnostic Information</h2> 23</div> 24<p>Boost Exception provides a namespace-scope function <span class="RenoLink"><a href="diagnostic_information.html">diagnostic_information</a></span> which takes a boost::<span class="RenoLink"><a href="exception.html">exception</a></span>. The returned string contains:</p> 25<div><ul><li>the string representation of all data objects added to the boost::<span class="RenoLink"><a href="exception.html">exception</a></span> through <span class="RenoLink"><a href="exception_operator_shl.html">operator<<</a></span>;</li> 26<li>the output from std::exception::what;</li> 27<li>additional platform-specific diagnostic information.</li> 28</ul></div> 29<p>The returned string 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> 30<pre>#include <<span class="RenoLink"><a href="boost_exception_all_hpp.html">boost/exception/all.hpp</a></span>> 31#include <iostream> 32 33void f(); //throws unknown types that derive from boost::<span class="RenoLink"><a href="exception.html">exception</a></span>. 34 35void 36g() 37 { 38 try 39 { 40 f(); 41 } 42 catch( 43 boost::<span class="RenoLink"><a href="exception.html">exception</a></span> & e ) 44 { 45 std::cerr << <span class="RenoLink"><a href="diagnostic_information.html">diagnostic_information</a></span>(e); 46 } 47 }</pre> 48<div class="RenoIncludeDIV"><h4>Example:</h4> 49<p>this is a possible output from the <span class="RenoLink"><a href="diagnostic_information.html">diagnostic_information</a></span> function, as used in <i>libs/exception/example/example_io.cpp:</i></p> 50<pre>example_io.cpp(70): Throw in function class boost::shared_ptr<struct _iobuf> __cdecl my_fopen(const char *,const char *) 51Dynamic exception type: class boost::exception_detail::clone_impl<struct fopen_error> 52std::exception::what: example_io error 53[struct boost::<span class="RenoLink"><a href="errinfo_api_function.html">errinfo_api_function</a></span>_ *] = fopen 54[struct boost::<span class="RenoLink"><a href="errinfo_errno.html">errinfo_errno</a></span>_ *] = 2, "No such file or directory" 55[struct boost::<span class="RenoLink"><a href="errinfo_file_name.html">errinfo_file_name</a></span>_ *] = tmp1.txt 56[struct boost::<span class="RenoLink"><a href="errinfo_file_open_mode.html">errinfo_file_open_mode</a></span>_ *] = rb</pre> 57</div></div><div class="RenoAutoDIV"><div class="RenoHR"><hr/></div> 58See also: <span class="RenoPageList"><a href="boost-exception.html">Boost Exception</a></span> 59</div> 60<!-- Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc. --> 61<!-- Distributed under the Boost Software License, Version 1.0. (See accompanying --> 62<!-- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) --> 63<div id="footer"> 64<p> 65<a class="logo" href="http://jigsaw.w3.org/css-validator/check/referer"><img class="logo_pic" src="valid-css.png" alt="Valid CSS" height="31" width="88"/></a> 66<a class="logo" href="http://validator.w3.org/check?uri=referer"><img class="logo_pic" src="valid-xhtml.png" alt="Valid XHTML 1.0" height="31" width="88"/></a> 67<small>Copyright (c) 2006-2009 by Emil Dotchevski and Reverge Studios, Inc.<br/> 68Distributed under the <a href="http://www.boost.org/LICENSE_1_0.txt">Boost Software License, Version 1.0</a>.</small> 69</p> 70</div> 71</div> 72</div> 73</div> 74</body> 75</html> 76