Namespaces
Variants
Views
Actions

Difference between revisions of "cpp/error"

From cppreference.com
< cpp
(Assert: use correct template)
(formatting)
Line 1: Line 1:
 
{{title|Error handling}}
 
{{title|Error handling}}
 
{{cpp/error/sidebar}}
 
{{cpp/error/sidebar}}
==Exceptions==
+
===Exceptions===
  
 
The class {{rlt | exception/exception | exception}} provides a common interface to signal for error conditions through the [[cpp/language/throw | throw expression]].
 
The class {{rlt | exception/exception | exception}} provides a common interface to signal for error conditions through the [[cpp/language/throw | throw expression]].
  
===Exception categories===
+
====Exception categories====
  
 
Several convenience classes are predefined to report particular error conditions. These classes can be divided into two categories: ''logic'' errors and ''runtime'' errors. Logic errors are a consequence of faulty logic within the program and may be preventable. Runtime errors are due to events beyond the scope of the program and can not be easily predicted.
 
Several convenience classes are predefined to report particular error conditions. These classes can be divided into two categories: ''logic'' errors and ''runtime'' errors. Logic errors are a consequence of faulty logic within the program and may be preventable. Runtime errors are due to events beyond the scope of the program and can not be easily predicted.
Line 19: Line 19:
 
:*{{ltt|cpp/error/exception/underflow_error}}
 
:*{{ltt|cpp/error/exception/underflow_error}}
  
==Error numbers==
+
===Error numbers===
  
 
{{rl | errno | Several macros}} are available, that provide POSIX error number support. An {{tt|errno}} variable is also supported, a separate value is given to each thread.
 
{{rl | errno | Several macros}} are available, that provide POSIX error number support. An {{tt|errno}} variable is also supported, a separate value is given to each thread.
  
==Assert==
+
===Assert===
  
 
{{rlt|assert}} macro aborts the program if the user-specified condition is not true.
 
{{rlt|assert}} macro aborts the program if the user-specified condition is not true.

Revision as of 12:54, 9 August 2011

Template:cpp/error/sidebar

Contents

Exceptions

The class exception provides a common interface to signal for error conditions through the throw expression.

Exception categories

Several convenience classes are predefined to report particular error conditions. These classes can be divided into two categories: logic errors and runtime errors. Logic errors are a consequence of faulty logic within the program and may be preventable. Runtime errors are due to events beyond the scope of the program and can not be easily predicted.

Error numbers

Several macros are available, that provide POSIX error number support. An errno variable is also supported, a separate value is given to each thread.

Assert

assert macro aborts the program if the user-specified condition is not true.

static_assert function renders the program ill-formed if the user-specified condition is not true Template:mark c++11 feature.

System error