libtabula::BadQuery Class Reference

Exception thrown when the database server encounters a problem while processing your query. More...

#include <exceptions.h>

Inheritance diagram for libtabula::BadQuery:
Inheritance graph
[legend]
Collaboration diagram for libtabula::BadQuery:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 BadQuery (const char *w="", int e=0)
 Create exception object.
 BadQuery (const std::string &w, int e=0)
 Create exception object.
int errnum () const
 Return the error number corresponding to the error message returned by what().

Detailed Description

Exception thrown when the database server encounters a problem while processing your query.

Unlike most other Libtabula exceptions, which carry just an error message, this type carries an error number to preserve Connection::errnum()'s return value at the point the exception is thrown. We do this because when using the Transaction class, the rollback process that occurs during stack unwinding issues a query to the database server, overwriting the error value. This rollback should always succeed, so this effect can fool code that relies on Connection::errnum() into believing that there was no error.

Beware that in older versions of Libtabula, this was effectively the generic exception type. (This is most especially true in v1.7.x, but it continued to a lesser extent through the v2.x series.) When converting old code to new versions of Libtabula, it's therefore possible to get seemingly "new" exceptions thrown, which could crash your program if you don't also catch a more generic type like libtabula::Exception or std::exception.


Constructor & Destructor Documentation

libtabula::BadQuery::BadQuery ( const char *  w = "",
int  e = 0 
) [inline, explicit]

Create exception object.

Parameters:
w explanation for why the exception was thrown
e the error number from the underlying database API
libtabula::BadQuery::BadQuery ( const std::string &  w,
int  e = 0 
) [inline, explicit]

Create exception object.

Parameters:
w explanation for why the exception was thrown
e the error number from the underlying database API

Member Function Documentation

int libtabula::BadQuery::errnum (  )  const [inline]

Return the error number corresponding to the error message returned by what().

This may return the same value as Connection::errnum(), but not always. See the overview documentation for this class for the reason for the difference.


The documentation for this class was generated from the following file:

Generated on 26 May 2014 for Libtabula by  doxygen 1.6.1