List:MySQL++« Previous MessageNext Message »
From:Jake Colman Date:November 25 2013 4:20pm
Subject:Re: Problem Catching BadQuery Exception
View as plain text  
Warren,

I must have misread the docs because I though that a connection object
defaulted to throwing exceptions unless 'false' was passed into the
constructor.  I modified my code to construct the object with 'true' and
all is working perfectly now.

Thanks.


*Jake Colman*

*Director, Development *| Billtrust

Tel: 609.235.0792 | email: jcolman@stripped | Web: www.billtrust.com

Follow us: Twitter <http://www.twitter.com/billtrust>|
Facebook<http://www.facebook.com/Billtrust.CompleteBilling>|
LinkedIn <http://www.linkedin.com/company/99112> |
Blog<http://blog.billtrust.com/>


On Mon, Nov 25, 2013 at 11:08 AM, Warren Young <mysqlpp@stripped> wrote:

> On 11/25/2013 06:38, Jake Colman wrote:
>
>> The connection object is created with the default
>> constructor so I'm expecting exceptions to be thrown.
>>
>
> Strictly speaking, Connection has no default ctor.
>
> One of the ctors takes a single parameter with a default value that
> enables exceptions, but you could pass false here instead.
>
>
>  When I execute the
>> SELECT using the Query::store() method the exception is not being thrown.
>>
>
> With this trivial patch to MySQL++, the example *does* throw a BadQuery
> exception:
>
> Index: examples/ssqls3.cpp
> ===================================================================
> --- examples/ssqls3.cpp (revision 2735)
> +++ examples/ssqls3.cpp (working copy)
> @@ -49,7 +49,7 @@
>
>         // Build a query to retrieve the stock item that has Unicode
>         // characters encoded in UTF-8 form.
> -       mysqlpp::Query query = con.query("select * from stock ");
> +       mysqlpp::Query query = con.query("select * from stockx ");
>         query << "where item = " << mysqlpp::quote <<
> "Nürnberger Brats";
>
>         // Retrieve the row, throwing an exception if it fails.
>
> A BadQuery exception continues to be thrown if you rename 'con' to 'con_'
> and create a copy of it as 'con' to force use of the copy ctor.
>
> What does Connection::throw_exceptions() return in your program?  Make the
> call immediately before the failing query, to be sure the flag isn't
> changing value between construction and query.
>
>
>  If you need more info, I'll send a few lines of code that demonstrate the
>> problem.
>>
>
> Best to patch one of the examples, since that removes the schema and other
> details as sources of confusion.  If you find that the examples work and
> your code doesn't, study the differences between your code and the
> examples, and try to make one of the two behave like the other.
>
>
>
> --
> MySQL++ Mailing List
> For list archives: http://lists.mysql.com/plusplus
> To unsubscribe:    http://lists.mysql.com/plusplus
>
>

Thread
Problem Catching BadQuery ExceptionJake Colman25 Nov
  • Re: Problem Catching BadQuery ExceptionWarren Young25 Nov
    • Re: Problem Catching BadQuery ExceptionJake Colman25 Nov
      • Re: Problem Catching BadQuery ExceptionWarren Young25 Nov
        • Re: Problem Catching BadQuery ExceptionJake Colman25 Nov
          • Re: Problem Catching BadQuery ExceptionWarren Young25 Nov
            • Re: Problem Catching BadQuery ExceptionJake Colman25 Nov
              • Re: Problem Catching BadQuery ExceptionWarren Young25 Nov
                • Re: Problem Catching BadQuery ExceptionJake Colman25 Nov
                  • Re: Problem Catching BadQuery ExceptionWarren Young25 Nov
                    • Re: Problem Catching BadQuery ExceptionJake Colman25 Nov
        • Re: Problem Catching BadQuery ExceptionJonathan Wakely25 Nov