If you compile with the "--with-exception" flag turned on, all exceptions generated will
derive from std::exception and you can use the what() method to find out what exception
is thrown.
BTW, make sure you use "--with-exception" not "--with-exceptions"; don't ask me how I
know.
-SR
> -----Original Message-----
> From: news [mailto:news@stripped] On Behalf Of Ney André
> de Mello Zunino
> Sent: Wednesday, January 05, 2005 9:50 AM
> To: plusplus@stripped
> Subject: MySQL++ issue with exceptions
>
> Hello.
>
> An exception is being throw upon the execution of an insert
> query. I would like to know the exact type of exception, but
> I haven't managed to do so as I can only seem to catch it by
> using the catch-all syntax. Here is the relevant code snippet:
>
> try
> {
> query.execute();
> }
> catch (const BadQuery& exception) {
> cerr << "BadConversion\n";
> }
> catch (const BadConversion& exception) {
> cerr << "BadConversion\n";
> }
> catch (const BadNullConversion& exception) {
> cerr << "BadNullConversion";
> }
> catch (const SQLQueryNEParms& exception) {
> cerr << "SQLQueryNEParms";
> }
> catch (const exception& exception) {
> cerr << "std::exception happened in the execution of the
> query.\n";
> }
> catch (...) {
> cerr << "Something bad happened; I wish I knew what it is.\n";
> }
>
> The questions:
>
> 1) What are all the possible exceptions thrown by the MySQL++
> API? I have found the above ones by looking into the source
> code. Is that the only resource?
>
> 2) I think the exception is happening when the insert
> violates the uniqueness of the primary key. Shouldn't there
> be a specific exception for that?
>
> 3) In any case, how come the exception generated is not
> derived from std::exception? FWIW, I am using
> /DUSE_STANDARD_EXCEPTION upon building.
>
> Thank you very much,
>
> --
> Ney André de Mello Zunino
>
>
> --
> MySQL++ Mailing List
> For list archives: http://lists.mysql.com/plusplus
> To unsubscribe:
> http://lists.mysql.com/plusplus?unsub=1
>
>
>