Shouldn't throw built-in exceptions?

V

Victor Bazarov

J

Jakob Bieling

Joe Van Dyk said:
The FAQ at
http://www.parashift.com/c++-faq-lite/exceptions.html#faq-17.6 says
that you shouldn't throw built-in exceptions.

I'm not sure why I shouldn't throw something like std::domain_error
though -- if it does all that I want it to do.

It did not say 'do not throw built-in exceptions' but 'do not throw
built-ins'. A built-in [type] is an 'int' or a 'char*'. At least how I
understood this. I do not see anything wrong with throwing an
std::runtime_exception, if it suits your needs

hth
 
J

Jakob Bieling

Jakob Bieling said:
understood this. I do not see anything wrong with throwing an
std::runtime_exception, if it suits your needs

Err, std::runtime_error ;-)
 
J

Joe Van Dyk

Victor said:
The FAQ says nothing of the kind. Read it again. It recommends against
throwing built-in _types_ (like 'int' or 'char*'), not standard exceptions.




By all means, throw it.

V


Ah, ok. They gave an example of throwing an exception object that
inherits from a standard exception, so I thought that's what the FAQ was
saying.

Thanks!
Joe
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top