tutorial_diagnostic_information.html 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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&lt;&lt;</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 &lt;<span class="RenoLink"><a href="boost_exception_all_hpp.html">boost/exception/all.hpp</a></span>&gt;
  31. #include &lt;iostream&gt;
  32. void f(); //throws unknown types that derive from boost::<span class="RenoLink"><a href="exception.html">exception</a></span>.
  33. void
  34. g()
  35. {
  36. try
  37. {
  38. f();
  39. }
  40. catch(
  41. boost::<span class="RenoLink"><a href="exception.html">exception</a></span> &amp; e )
  42. {
  43. std::cerr &lt;&lt; <span class="RenoLink"><a href="diagnostic_information.html">diagnostic_information</a></span>(e);
  44. }
  45. }</pre>
  46. <div class="RenoIncludeDIV"><h4>Example:</h4>
  47. <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>
  48. <pre>example_io.cpp(70): Throw in function class boost::shared_ptr&lt;struct _iobuf&gt; __cdecl my_fopen(const char *,const char *)
  49. Dynamic exception type: class boost::exception_detail::clone_impl&lt;struct fopen_error&gt;
  50. std::exception::what: example_io error
  51. [struct boost::<span class="RenoLink"><a href="errinfo_api_function.html">errinfo_api_function</a></span>_ *] = fopen
  52. [struct boost::<span class="RenoLink"><a href="errinfo_errno.html">errinfo_errno</a></span>_ *] = 2, "No such file or directory"
  53. [struct boost::<span class="RenoLink"><a href="errinfo_file_name.html">errinfo_file_name</a></span>_ *] = tmp1.txt
  54. [struct boost::<span class="RenoLink"><a href="errinfo_file_open_mode.html">errinfo_file_open_mode</a></span>_ *] = rb</pre>
  55. </div></div><div class="RenoAutoDIV"><div class="RenoHR"><hr/></div>
  56. See also: <span class="RenoPageList"><a href="boost-exception.html">Boost Exception</a></span>
  57. </div>
  58. <!-- Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc. -->
  59. <!-- Distributed under the Boost Software License, Version 1.0. (See accompanying -->
  60. <!-- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -->
  61. <div id="footer">
  62. <p>
  63. <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>
  64. <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>
  65. <small>Copyright (c) 2006-2009 by Emil Dotchevski and Reverge Studios, Inc.<br/>
  66. Distributed under the <a href="http://www.boost.org/LICENSE_1_0.txt">Boost Software License, Version 1.0</a>.</small>
  67. </p>
  68. </div>
  69. </div>
  70. </div>
  71. </div>
  72. </body>
  73. </html>