[snip]
>On 4/14/2011 5:33 PM, Dan Cook (dancook) wrote:
>>
>> Thanks again for the patch. I have applied the patch and rebuilt the
>> library.
>
>I didn't make it clear, but you also have to change your code. With
the
>patch installed, MySQL++ will throw an exception (or if exceptions are
>disabled, make the Query object false) when the MySQL C API library
does
>this. It doesn't prevent the C API library from barfing, and it
doesn't
>magically create error-handling code in your program.
>
>Not ideal, but greatly preferable to crashing, I hope.
Warren,
Thank you for the clarification. We let the mysqlpp code throw
exceptions and all of our database query code is "surrounded" by
try/catch blocks straight from the sample code. The UseQueryError
should be caught in the catch all mysqpp::Exception ... I hope. So in
theory we should see a highly intuitive "Bogus empty result" returned to
our upper layers as the error message. ;) Of course we will probably
have to do more changes, but if it does crash in the upper layers, it's
because they didn't handle the error condition not because we barfed.
std::string emsg;
...
try {
...
} catch (const mysqlpp::BadQuery& er) {
emsg.assign(er.what());
} catch (const mysqlpp::BadConversion& er) {
std::ostringstream sstream;
sstream << "Conversion error: " << er.what() <<
" retrieved data size: " << er.retrieved <<
", actual size: " << er.actual_size;
emsg.assign(sstream.str());
} catch (const mysqlpp::Exception& er) {
emsg.assign(er.what());
}
Dan Cook