Topic: catch exceptions


Author: "Francisco Javier Sanchez Maya" <franciscojsm@meta4.es>
Date: 1999/03/16
Raw View
I'd like catch operating system exceptions such as "Integer Divided By Zero"
and get its type.

With the expresion:

    try {
        ....
    }
    catch (...) {
        ....
    }

I can get all the exceptions but I can't get what exception has been thrown.

Thanks



[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]






Author: Christopher Eltschka <celtschk@physik.tu-muenchen.de>
Date: 1999/03/16
Raw View
Francisco Javier Sanchez Maya wrote:
>
> I'd like catch operating system exceptions such as "Integer Divided By Zero"
> and get its type.
>
> With the expresion:
>
>     try {
>         ....
>     }
>     catch (...) {
>         ....
>     }
>
> I can get all the exceptions but I can't get what exception has been thrown.

The standard doesn't define exceptions for this. So if your
implementation maps division by zero and similar errors to
exceptions, you must read the documentation of your compiler
to find out what exceptions are thrown (or alternatively, ask
in a newsgroup for your compiler).

However, note that this makes your program non-portable.
Most platforms don't convert those errors into exceptions.
The standard doesn't tell you what should happen; usual
results are
- raised signals (f.ex. under UNIX)
- special values in float operations (f.ex. IEEE Inf/NaN)
However, a platform could also just ignore it and produce
random results.


[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]