- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Hierarchy
- Class Members

# mysqlpp::BadQuery Class Reference

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

`#include <exceptions.h>`

Inheritance diagram for mysqlpp::BadQuery:

[legend]
Collaboration diagram for mysqlpp::BadQuery:

[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 MySQL++ 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 MySQL++, 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 MySQL++, 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 mysqlpp::Exception or std::exception.

## Constructor & Destructor Documentation

mysqlpp::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

mysqlpp::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 mysqlpp::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:

- exceptions.h