TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: KEVIN KRUMWIEDE
from: CAMERON CLARK
date: 1997-09-26 15:12:00
subject: Re: Exceptions

KK> If a function has an exception list specified, and it throws an
KK> exception not on the list, unexpected() will be called.  But if the
KK> function has no exception specification, any thrown exception will be
KK> passed back to the caller, and if the caller can't catch it, to the
KK> caller's caller, etc.  Right?
    I'm no expert on C++'s implemenation of exceptions, but here's
    the gist:
    Exception handling is passing the buck: you allow errors to
    be handled by the caller (or the caller of the caller).
    A dirty example is the following.
    IOClass io;
    int i;
    try { io.read >> i; } catch (...) { cout << "Exception caught\n";}
    try { io.write << i; } catch (...) ( cout << "Exception caught\n";}
    // Assuming that io.read/write are designed to throw and exception
    // Yes, you could have had just
    //   try {io.read >> i; io.write << i;}.
    Java has a very good implementation of exceptions. It is an error
    not to handle an exception (or declare exceptions will be re-thrown).
    You might want to look for a Java example to help expain C++'s use.
--- GEcho 1.00
---------------
* Origin: Digital OnLine Magazine! - (409)838-8237 (1:3811/350)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.