简体   繁体   中英

How to guess the exception type thrown by libpqxx C++ library functions?

I'm using libpqxx but I'm stuck with the following.

Some function of lets say the pqxx:connection_base class throw exception, as per the connection_base.hxx file :

void disconnect() throw ();

My question is : how can I guess what kind of exception is thrown ? Shall I expect a pqxx::exception , a pqxx::sql_error ? The include files seems useless to me, and the documentation, a Doxygen generated one obviously doesn't help.

void disconnect() throw ();
                  ^^^^^^^^^^

An Exception specification with empty throw tells you that this function will not throw any exceptions .

You should not guess what exception the function shows, either the function shouldn't include any exception specification which means it can throw any exception(can be caught by catch all handler catch(...) Note: this is a bad practice ) or it should document which exceptions it can throw.

In this case atleast the documentation says it should not throw any exception, if it does otherwise report it to the provider of the function.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM