List:MySQL++« Previous MessageNext Message »
From:Warren Young Date:January 7 2010 10:06pm
Subject:Re: Query::execute crashes without a connected driver
View as plain text  
On 1/7/2010 6:15 AM, Joel Fielder wrote:
>
> This may be expected behaviour, but if throw_exceptions is true it still
> crashes where I'd expect an exception. Would you agree?

Reasonable.

> I wasn't sure of what should happen to
> copacetic_ flag

It should probably be set to false.  Else, this doesn't work right:

	Connection c(false);	// no exceptions
	Query q = c.query("select foo from bar bla bla bla");
	SimpleResult r = q.execute();
	if (q) {
		// it gets here
	}
	else {
		// not here like you might expect
	}

> which exception would be most appropriate to throw!

If you want to use an existing one, I like ConnectionFailed.  If you 
feel that's misleading, you can define a new one.  I'm not shy about 
adding exception types when warranted.

> I've also made it return SimpleResult() if not connected but maybe you
> still want it to break?

No, you followed the existing pattern later in the routine.

I don't want to apply this as-is even with the suggested changes, 
though, because it probably affects much more than just execute(); 
exec(), store*(), use()...  Maybe even high-level methods like insertfrom().
Thread
Query::execute crashes without a connected driverJoel Fielder7 Jan
  • Re: Query::execute crashes without a connected driverWarren Young7 Jan
    • Re: Query::execute crashes without a connected driverJoel Fielder8 Jan
    • mysqlpp::ScopedConnectionJoel Fielder8 Jan
      • Re: mysqlpp::ScopedConnectionWarren Young9 Jan
        • Re: mysqlpp::ScopedConnectionJonathan Wakely9 Jan
          • Re: mysqlpp::ScopedConnectionJoel Fielder11 Jan
            • Re: mysqlpp::ScopedConnectionJonathan Wakely11 Jan
              • Re: mysqlpp::ScopedConnectionWarren Young11 Jan
                • Re: mysqlpp::ScopedConnectionJonathan Wakely11 Jan
    • Re: Query::execute crashes without a connected driverJoel Fielder13 Jan
      • Re: Query::execute crashes without a connected driverWarren Young13 Jan
Re: mysqlpp::ScopedConnectionJoel Fielder11 Jan
  • Re: mysqlpp::ScopedConnectionWarren Young11 Jan
    • Re: mysqlpp::ScopedConnectionJoel Fielder11 Jan
      • Re: mysqlpp::ScopedConnectionWarren Young11 Jan
        • Re: mysqlpp::ScopedConnectionJoel Fielder12 Jan