List:MySQL++« Previous MessageNext Message »
From:Chris Morgan Date:December 22 2010 4:38am
Subject:Re: Exception Handling.
View as plain text  
On Tue, Dec 21, 2010 at 18:29, Eric Sepich <sepich.eric@stripped> wrote:

> First off I saw an example outlining how to use:
>
>        #include <mysql++.h>
>        mysqlpp::Connection conn(use_exceptions);
>
> For me it does not work. My compiler tells me there is no definition for
> use_exceptions. Also I need to add error handling to the following query as
> it exists in my code:
>

Hi Eric,

I'm guessing you saw the (uncompilable) example on this page:
http://www.rdrop.com/docs/mysql/4_Tutorial.html (section 4.4.2).  Since the
author of that page never defined the use_exceptions variable, the compiler
will complain that it is undefined.  The mysqlpp::Connection constructor
takes a bool that enables or disables exceptions, which is defaulted to use
exceptions:
http://tangentsoft.net/mysql++/doc/html/userman/tutorial.html#exceptions.

mysqlpp::Query fquery = pconn->query(squery);
> mysqlpp::StoreQueryResult fres = fquery.store();
>
> From what I have read in the reference manual there is a BadQuery class.
> Also there is some StdErr class. There really is no good example I can find
> describing the how of exception handling in mysql++.
>
> If you look at tquery1.cpp (which comes with the mysql++ source in
examples/ and is available via SVN here:
http://svn.gna.org/viewcvs/mysqlpp/trunk/examples/tquery1.cpp?revision=2469&view=markupyou
can find a straightforward example of using try/catch blocks with
"common" mysql++ exceptions.

I'm not sure what you mean by StdErr.  mysqlpp::Exception derives from
std::exception.

HTH,

Chris

Thread
Exception Handling.Eric Sepich22 Dec
  • Re: Exception Handling.Chris Morgan22 Dec
  • Re: Exception Handling.Warren Young22 Dec