PageRenderTime 26ms CodeModel.GetById 22ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/www.cppreference.com/wiki/error/exception

https://github.com/tsgates/cclookup
#! | 119 lines | 106 code | 13 blank | 0 comment | 0 complexity | 0d26d0d351a8fc5874c70e964b713a89 MD5 | raw file
  1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
  4 lang="en" dir="ltr">
  5<head>
  6  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  7  <title>error:exception</title>
  8<meta name="generator" content="DokuWiki" />
  9<meta name="robots" content="index,follow" />
 10<meta name="date" content="2010-11-11T14:26:07-0800" />
 11<meta name="keywords" content="error,exception" />
 12<link rel="search" type="application/opensearchdescription+xml" href="http://www.cppreference.com/wiki/lib/exe/opensearch.php" title="C++ Reference" />
 13<link rel="start" href="../../index.html" />
 14<link rel="contents" href="http://www.cppreference.com/wiki/error/exception?do=index" title="Sitemap" />
 15<link rel="alternate" type="application/rss+xml" title="Recent Changes" href="http://www.cppreference.com/wiki/feed.php" />
 16<link rel="alternate" type="application/rss+xml" title="Current Namespace" href="http://www.cppreference.com/wiki/feed.php?mode=list&amp;ns=error" />
 17<link rel="alternate" type="text/html" title="Plain HTML" href="http://www.cppreference.com/wiki/_export/xhtml/error/exception" />
 18<link rel="alternate" type="text/plain" title="Wiki Markup" href="http://www.cppreference.com/wiki/_export/raw/error/exception" />
 19<link rel="canonical" href="exception" />
 20<link rel="stylesheet" media="screen" type="text/css" href="../lib/exe/css.php@t=custom1&amp;tseed=1289693594" />
 21<link rel="stylesheet" media="all" type="text/css" href="../lib/exe/css.php@s=all&amp;t=custom1&amp;tseed=1289693594" />
 22<link rel="stylesheet" media="print" type="text/css" href="../lib/exe/css.php@s=print&amp;t=custom1&amp;tseed=1289693594" />
 23<script type="text/javascript" ><!--//--><![CDATA[//><!--
 24var NS='error';var JSINFO = {"id":"error:exception","namespace":"error"};
 25//--><!]]></script>
 26<script type="text/javascript" charset="utf-8" src="../lib/exe/js.php@tseed=1289693594" ></script>
 27</head>
 28<body>
 29<div class="dokuwiki export">
 30<!-- TOC START -->
 31<div class="toc">
 32<div class="tocheader toctoggle" id="toc__header">Table of Contents</div>
 33<div id="toc__inside">
 34
 35<ul class="toc">
 36<li class="clear">
 37
 38<ul class="toc">
 39<li class="level2"><div class="li"><span class="li"><a href="exception#exceptions" class="toc">Exceptions</a></span></div>
 40<ul class="toc">
 41<li class="level3"><div class="li"><span class="li"><a href="exception#handling" class="toc">Handling</a></span></div></li>
 42<li class="level3"><div class="li"><span class="li"><a href="exception#standard_exceptions" class="toc">Standard Exceptions</a></span></div></li></ul>
 43</li></ul>
 44</li></ul>
 45</div>
 46</div>
 47<!-- TOC END -->
 48
 49<h2 class="sectionedit1"><a name="exceptions" id="exceptions">Exceptions</a></h2>
 50<div class="level2">
 51
 52</div>
 53<!-- EDIT1 SECTION "Exceptions" [1-23] -->
 54<h3 class="sectionedit2"><a name="handling" id="handling">Handling</a></h3>
 55<div class="level3">
 56
 57<p>
 58The <code>&lt;exception&gt;</code> header provides functions and classes for exception control. One basic class is <code>exception</code>:
 59
 60</p>
 61<pre class="cpp code cpp"><span class="kw2">class</span> exception
 62<span class="br0">&#123;</span>
 63<span class="kw2">public</span><span class="sy4">:</span>
 64    exception<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="kw1">throw</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy4">;</span>
 65    exception<span class="br0">&#40;</span><span class="kw4">const</span> exception<span class="sy3">&amp;</span><span class="br0">&#41;</span> <span class="kw1">throw</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy4">;</span>
 66    exception<span class="sy3">&amp;</span> operator<span class="sy1">=</span><span class="br0">&#40;</span><span class="kw4">const</span> exception<span class="sy3">&amp;</span><span class="br0">&#41;</span> <span class="kw1">throw</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy4">;</span>
 67    <span class="kw2">virtual</span> ~exception<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="kw1">throw</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy4">;</span>
 68    <span class="kw2">virtual</span> <span class="kw4">const</span> <span class="kw4">char</span> <span class="sy2">*</span>what<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="kw4">const</span> <span class="kw1">throw</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy4">;</span>
 69<span class="br0">&#125;</span><span class="sy4">;</span></pre>
 70</div>
 71<!-- EDIT2 SECTION "Handling" [24-404] -->
 72<h3 class="sectionedit3"><a name="standard_exceptions" id="standard_exceptions">Standard Exceptions</a></h3>
 73<div class="level3">
 74
 75<p>
 76The <code>&lt;stdexcept&gt;</code> header provides a small hierarchy of exception classes that can be <a href="../keywords/throw" class="wikilink1" title="keywords:throw">thrown</a> or <a href="../keywords/catch" class="wikilink1" title="keywords:catch">caught</a>:
 77
 78</p>
 79<ul>
 80<li class="level1"><div class="li"> <code>exception</code></div>
 81<ul>
 82<li class="level2"><div class="li"> <code>logic_error</code></div>
 83<ul>
 84<li class="level3"><div class="li"> <code>domain_error</code></div>
 85</li>
 86<li class="level3"><div class="li"> <code>invalid_argument</code></div>
 87</li>
 88<li class="level3"><div class="li"> <code>length_error</code></div>
 89</li>
 90<li class="level3"><div class="li"> <code>out_of_range</code></div>
 91</li>
 92</ul>
 93</li>
 94<li class="level2"><div class="li"> <code>runtime_error</code></div>
 95<ul>
 96<li class="level3"><div class="li"> <code>range_error</code></div>
 97</li>
 98<li class="level3"><div class="li"> <code>overflow_error</code></div>
 99</li>
100<li class="level3"><div class="li"> <code>underflow_error</code></div>
101</li>
102</ul>
103</li>
104</ul>
105</li>
106</ul>
107
108<p>
109
110<em>Logic</em> errors are thrown if the program has internal errors that are caused by the user of a function and that, in theory, are preventable.<br/>
111
112<em>Runtime</em> errors are thrown if the cause is beyond the program and can&#039;t be predicted by the user of a function.
113
114</p>
115
116</div>
117<!-- EDIT3 SECTION "Standard Exceptions" [405-] --></div>
118</body>
119</html>