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