Merged r158465 through r158660 into branch.
[official-gcc.git] / libstdc++-v3 / doc / html / manual / diagnostics.html
blobd04585fbcd970c5d4ff163fd6b4a251c7b92a509
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"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Chapter 5.  Diagnostics</title><meta name="generator" content="DocBook XSL Stylesheets V1.75.2" /><meta name="keywords" content="&#10; ISO C++&#10; , &#10; library&#10; " /><link rel="home" href="../spine.html" title="The GNU C++ Library Documentation" /><link rel="up" href="bk01pt02.html" title="Part II.  Standard Contents" /><link rel="prev" href="termination.html" title="Termination" /><link rel="next" href="bk01pt02ch05s02.html" title="Concept Checking" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 5
4 Diagnostics
6 </th></tr><tr><td width="20%" align="left"><a accesskey="p" href="termination.html">Prev</a> </td><th width="60%" align="center">Part II. 
7 Standard Contents
8 </th><td width="20%" align="right"> <a accesskey="n" href="bk01pt02ch05s02.html">Next</a></td></tr></table><hr /></div><div class="chapter" title="Chapter 5.  Diagnostics"><div class="titlepage"><div><div><h2 class="title"><a id="std.diagnostics"></a>Chapter 5
9 Diagnostics
10 <a id="id477731" class="indexterm"></a>
11 </h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="sect1"><a href="diagnostics.html#std.diagnostics.exceptions">Exceptions</a></span></dt><dd><dl><dt><span class="sect2"><a href="diagnostics.html#std.diagnostics.exceptions.api">API Reference</a></span></dt><dt><span class="sect2"><a href="diagnostics.html#std.diagnostics.exceptions.data">Adding Data to <code class="classname">exception</code></a></span></dt></dl></dd><dt><span class="sect1"><a href="bk01pt02ch05s02.html">Concept Checking</a></span></dt></dl></div><div class="sect1" title="Exceptions"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="std.diagnostics.exceptions"></a>Exceptions</h2></div></div></div><div class="sect2" title="API Reference"><div class="titlepage"><div><div><h3 class="title"><a id="std.diagnostics.exceptions.api"></a>API Reference</h3></div></div></div><p>
12 All exception objects are defined in one of the standard header
13 files: <code class="filename">exception</code>,
14 <code class="filename">stdexcept</code>, <code class="filename">new</code>, and
15 <code class="filename">typeinfo</code>.
16 </p><p>
17 The base exception object is <code class="classname">exception</code>,
18 located in <code class="filename">exception</code>. This object has no
19 <code class="classname">string</code> member.
20 </p><p>
21 Derived from this are several classes that may have a
22 <code class="classname">string</code> member: a full hierarchy can be
23 found in the source documentation.
24 </p><p>
25 Full API details.
26 </p></div><div class="sect2" title="Adding Data to exception"><div class="titlepage"><div><div><h3 class="title"><a id="std.diagnostics.exceptions.data"></a>Adding Data to <code class="classname">exception</code></h3></div></div></div><p>
27 The standard exception classes carry with them a single string as
28 data (usually describing what went wrong or where the 'throw' took
29 place). It's good to remember that you can add your own data to
30 these exceptions when extending the hierarchy:
31 </p><pre class="programlisting">
32 struct My_Exception : public std::runtime_error
34 public:
35 My_Exception (const string&amp; whatarg)
36 : std::runtime_error(whatarg), e(errno), id(GetDataBaseID()) { }
37 int errno_at_time_of_throw() const { return e; }
38 DBID id_of_thing_that_threw() const { return id; }
39 protected:
40 int e;
41 DBID id; // some user-defined type
43 </pre></div></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="termination.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="bk01pt02.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="bk01pt02ch05s02.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Termination </td><td width="20%" align="center"><a accesskey="h" href="../spine.html">Home</a></td><td width="40%" align="right" valign="top"> Concept Checking</td></tr></table></div></body></html>