throw exception();



 DEVELOP > c-Plus-Plus > throw exception();

LINK TO THIS PAGE  


rating :  0   |  0


  Page 1 of 1

1

 
Topic: DEVELOP > c-Plus-Plus
User: "Dave"
Date: 16 Jan 2005 10:51:54 PM
Object: throw exception();
Josuttis states that I may not throw an exception of type exception or of
one of the standard exception types used for language support. Where in the
Standard am I forbidden from "throw exception();"?
Thanks,
Dave
.

User: "Roy Schestowitz"

Title: Re: throw exception(); 17 Jan 2005 12:12:59 AM
Dave wrote:

Josuttis states that I may not throw an exception of type exception or of
one of the standard exception types used for language support. Where in
the Standard am I forbidden from "throw exception();"?

I think the following will explain to you about all the exception types.
http://www.cplusplus.com/doc/tutorial/tut5-3.html

--
Roy Schestowitz
http://schestowitz.com
.
User: "Sebastian Redl"

Title: Re: throw exception(); 17 Jan 2005 02:11:06 AM
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
.



  Page 1 of 1

1

 


Related Articles
 

NEWER

pg.1232     pg.940     pg.716     pg.544     pg.412     pg.311     pg.234     pg.175     pg.130     pg.96     pg.70     pg.50     pg.35     pg.24     pg.16     pg.10     pg.6     pg.3     pg.1

OLDER