Hi,

I think that all exceptions are derived from std::exception...so u can use 
catch with std::exception

Trigve

----- Original Message ----
From: Marcel Loose <[EMAIL PROTECTED]>
To: [email protected]
Sent: Friday, January 19, 2007 4:22:30 PM
Subject: [libpqxx-general] [Q] How to easily catch all pqxx exceptions

Hi all,

I've been using libpqxx now for a bit more than a week and it looks
great.
There's one thing, though, that made me wonder. I want to isolate pqxx
specifics in my database access code inside a few "wrapper" classes.
This also means that no pqxx exception may escape. 
The problem I'm facing is that pqxx has four different top-level
exception classes (broken_connection, sql_error, in_double_error, and
internal_error). In order to not let any of those exceptions leak out,
I'll have to write a try/catch with 4 different catch blocks for each
call that may throw. This causes a lot of code duplication. 
Wouldn't it be a better idea to have one exception base class (e.g.
pqxx::base_exception) and derive the other pqxx exceptions from
base_exception, instead of deriving them form std::runtime_error and
std::logic_error?

Kind regards,

    Marcel Loose.

_______________________________________________
Libpqxx-general mailing list
[email protected]
http://gborg.postgresql.org/mailman/listinfo/libpqxx-general







 
____________________________________________________________________________________
Cheap talk?
Check out Yahoo! Messenger's low PC-to-Phone call rates.
http://voice.yahoo.com
_______________________________________________
Libpqxx-general mailing list
[email protected]
http://gborg.postgresql.org/mailman/listinfo/libpqxx-general

Reply via email to