Roy Schestowitz wrote:
> Dave wrote:
>
> I think the following will explain to you about all the exception types.
>
> http://www.cplusplus.com/doc/tutorial/tut5-3.html
>
There are some things in this document I'd like to point out.
First, not really relevant to the topic at hand, that it uses <iostream.h>,
when it really should use <iostream>.
Second, and more importantly, it's got the wrong reason listed for when a
bad_exception is thrown. The document claims it's when "an exception
doesn't match any catch". This is wrong. The exception is thrown when an
exception doesn't match an explicit throws clause:
void foo() throws (std::runtime_error)
{
throw std::length_error();
}
I'm not sure why Josuttis would state that you MAY NOT throw a plain
std::exception - as far as I'm aware, nothing in the standard says so. But
you SHOULD NOT throw a plain std::exception, simply because it holds no
further information to the cause of the error. Always be as specific as is
reasonable.
--
Sebastian Redl
|
|