16.2.2 Exceptions

back: built-in bool type
forward: casts
 
fastback: casts
up: changeable c++
fastforward: compiler quirks
top: autoconf, automake, and libtool
contents: table of contents
index: index
about: about this document

Exception handling is a language feature present in other modern programming languages. Ada and Java both have exception handling mechanisms. In essence, exception handling is a means of propogating a classified error by unwinding the procedure call stack until the error is caught by a higher procedure in the procedure call chain. A procedure indicates its willingness to handle a kind of error by catching it:

 
 void foo (); void func () {   try {     foo ();   }   catch (...) {     cerr << "foo failed!" << endl;   } } 

Conversely, a procedure can throw an exception when something goes wrong:

 
 typedef int io_error; void init () {   int fd;    fd = open ("/etc/passwd", O_RDONLY);   if (fd < 0) {     throw io_error(errno);   } } 

C++ compilers tend to implement exception handling in full, or not at all. If any C++ compiler you may be concerned with does not implement exception handling, you may wish to take the lowest common denominator approach and eliminate such code from your project.


This document was generated by Gary V. Vaughan on May, 24 2001 using texi2html


GNU Autoconf, Automake and Libtool
GNU Autoconf, Automake, and Libtool
ISBN: 1578701902
EAN: 2147483647
Year: 2002
Pages: 290

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net