Overview
Features
Download
Documentation
Community
Add-Ons & Services

more informative exception messages in Poco::Data [solved]

Please post support and help requests here.

more informative exception messages in Poco::Data [solved]

Postby mkaut » 20 Nov 2012, 10:39

Hello,

is it possible to get some more information about why an database operation failed?
I am using the MySQL driver and when I catch an exception, the what() method most of the time returns simply "MySQL" - so I have no idea why it crashed.
The only way I know of to find the source of the error is to open mysql in the terminal and try to repeat the operation(s) manually - then I can see an error message.
So my question is, is there some way to get the MySQL error message in my C++ code?

(I was inserting a long vector of entries and thought that it choked because I sent too much data - but then I found the offending row, tried to insert it manually and found that I have a duplicate primary index..)

Thanks a lot

Michal
Last edited by mkaut on 20 Nov 2012, 12:18, edited 1 time in total.
mkaut
 
Posts: 19
Joined: 17 Oct 2012, 15:22

Re: more informative exception messages in Poco::Data

Postby guenter » 20 Nov 2012, 10:45

Catching Poco::Exception instead of std::exception and calling displayText() should give you more info.

Code: Select all
try
{
    ... // MySQL operation
}
catch (Poco::Exception& exc)
{
    std::cerr << exc.displayText() << std::endl;
}
guenter
 
Posts: 1112
Joined: 11 Jul 2006, 16:27
Location: Austria

Re: more informative exception messages in Poco::Data

Postby mkaut » 20 Nov 2012, 12:17

guenter wrote:Catching Poco::Exception instead of std::exception and calling displayText() should give you more info.


Thanks a lot - exactly what I was looking for :-)
mkaut
 
Posts: 19
Joined: 17 Oct 2012, 15:22


Return to Support

Who is online

Users browsing this forum: No registered users and 2 guests