Topic: standard exceptions
Author: Valentin Bonnard <Bonnard.V@wanadoo.fr>
Date: 1999/10/24 Raw View
(Let me omit the std prefix.)
exception <exception>
|
+- logic_error <stdexcept>
| |
| +- out_of_range <stdexcept>
| +- domain_error <stdexcept>
| +- invalid_argument <stdexcept>
| +- length_error <stdexcept>
|
+- runtime_error <stdexcept>
| |
| +- range_error <stdexcept>
| +- overflow_error <stdexcept>
| +- underflow_error <stdexcept>
|
+- bad_alloc <new>
+- bad_typeid <typeinfo>
+- bad_cast <typeinfo>
+- bad_exception <exception>
Some examples:
new char[10000000000] -> bad_alloc (unless your
machine is really great)
char *p = NULL; typeid (*p) -> bad_typeid
Base b; dynamic_cast<Derived&> (b) -> bad_cast
string s; s.at(0) -> out_of_range
string (string::npos, 'X') -> length_error
bitset<10> ("Hello, world") -> invalid_argument
I don't think the standard library ever throws
domain_error, runtime_error, or any derived classes
(range_error, overflow_error, underflow_error).
--
Valentin Bonnard
---
[ 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: comeau@panix.com (Greg Comeau)
Date: 1999/10/22 Raw View
In article <7uie3a$no2$1@nnrp1.deja.com> ygillard@yahoo.com writes:
>I would like to know what are the exceptions that are defined by the
>AINSI C++ standard.
>Where are they defined (i.e header file),
>who (methods, operators, libraries..) throws them and what is the
>hierarchy.
All the following are from std::, found in <new>, <typeinfo>, <ios>
<exception> and <stdexcept>:
exception
bad_alloc (thrown by new)
bad_cast (thrown by dynamic_cast)
bad_exception (thrown by unexpected())
bad_typeid (thrown by typeid)
ios_base::failure
logic_error
domain_error (thrown by SL)
invalid_argument (thrown by SL)
length_error (thrown by SL)
out_of_range (thrown by SL)
runtime_error
overflow_error (thrown by SL)
range_error (thrown by SL)
underflow_error (thrown by SL)
The hierarchy is show by indentation above. The above is just a summary.
Why not get a copy of Standard C++ (see the link from my web site)
and a good up to date text (consider the books mentioned at
http://www.comeaucomputing.com/resources/litsuggs.html
Bring this list with you to your favorite bookstore,
spend a while browsing, get a few from each category.)
- Greg
--
Comeau Computing, 91-34 120th Street, Richmond Hill, NY, 11418-3214
Producers of Comeau C/C++ 4.2.38 -- NOTE 4.2.42 BETAS NOW AVAILABLE
Email: comeau@comeaucomputing.com / Voice:718-945-0009 / Fax:718-441-2310
*** WEB: http://www.comeaucomputing.com ***
---
[ 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: sirwillard@my-deja.com
Date: 1999/10/22 Raw View
In article <7uie3a$no2$1@nnrp1.deja.com>,
ygillard@yahoo.com wrote:
> Hello,
>
> I would like to know what are the exceptions that are defined by the
> AINSI C++ standard. Where are they defined (i.e header file), who
> (methods, operators, libraries..) throws them and what is the
> hierarchy.
Most of them are in <stdexcept>. There's very few, so you can figure
out the heirarchy yourself. The only important thing to know is that
all of them derive from std::exception. You honestly can't expect
anyone to list who throws them. If the compiler library is compliant
then any method you'd call will designate what exceptions they throw in
their throw specification, as in the following:
void bar() throw(foo) // The only two exceptions that can be thrown
// are foo and possibly bad_exception
{
...
}
Sent via Deja.com http://www.deja.com/
Before you buy.
---
[ 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: ygillard@yahoo.com
Date: 1999/10/21 Raw View
Hello,
I would like to know what are the exceptions that are defined by the
AINSI C++ standard. Where are they defined (i.e header file), who
(methods, operators, libraries..) throws them and what is the
hierarchy.
Thanks
Yves
Sent via Deja.com http://www.deja.com/
Before you buy.
---
[ 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 ]