Qt 4.8
|
The QSqlError class provides SQL database error information. More...
#include <qsqlerror.h>
Public Types | |
enum | ErrorType { NoError, ConnectionError, StatementError, TransactionError, UnknownError } |
This enum type describes the context in which the error occurred, e. More... | |
Public Functions | |
QString | databaseText () const |
Returns the text of the error as reported by the database. More... | |
QString | driverText () const |
Returns the text of the error as reported by the driver. More... | |
bool | isValid () const |
Returns true if an error is set, otherwise false. More... | |
int | number () const |
Returns the database-specific error number, or -1 if it cannot be determined. More... | |
QSqlError & | operator= (const QSqlError &other) |
Assigns the other error's values to this error. More... | |
QSqlError (const QString &driverText=QString(), const QString &databaseText=QString(), ErrorType type=NoError, int number=-1) | |
Constructs an error containing the driver error text driverText, the database-specific error text databaseText, the type type and the optional error number number. More... | |
QSqlError (const QSqlError &other) | |
Creates a copy of other. More... | |
void | setDatabaseText (const QString &databaseText) |
Sets the database error text to the value of databaseText. More... | |
void | setDriverText (const QString &driverText) |
Sets the driver error text to the value of driverText. More... | |
void | setNumber (int number) |
Sets the database-specific error number to number. More... | |
void | setType (ErrorType type) |
Sets the error type to the value of type. More... | |
QString | text () const |
This is a convenience function that returns databaseText() and driverText() concatenated into a single string. More... | |
ErrorType | type () const |
Returns the error type, or -1 if the type cannot be determined. More... | |
~QSqlError () | |
Destroys the object and frees any allocated resources. More... | |
Properties | |
QString | databaseError |
QString | driverError |
int | errorNumber |
ErrorType | errorType |
The QSqlError class provides SQL database error information.
A QSqlError object can provide database-specific error data, including the driverText() and databaseText() messages (or both concatenated together as text()), and the error number() and type(). The functions all have setters so that you can create and return QSqlError objects from your own classes, for example from your own SQL drivers.
Definition at line 53 of file qsqlerror.h.
enum QSqlError::ErrorType |
This enum type describes the context in which the error occurred, e.
g., a connection error, a statement error, etc.
\arg \b NoError No error occurred. \arg \b ConnectionError Connection error. \arg \b StatementError SQL statement syntax error. \arg \b TransactionError Transaction failed error. \arg \b UnknownError Unknown error. \arg \e None \arg \e Connection \arg \e Statement \arg \e Transaction \arg \e Unknown
Enumerator | |
---|---|
NoError | |
ConnectionError | |
StatementError | |
TransactionError | |
UnknownError |
Definition at line 56 of file qsqlerror.h.
QSqlError::QSqlError | ( | const QString & | driverText = QString() , |
const QString & | databaseText = QString() , |
||
ErrorType | type = NoError , |
||
int | number = -1 |
||
) |
Constructs an error containing the driver error text driverText, the database-specific error text databaseText, the type type and the optional error number number.
Definition at line 103 of file qsqlerror.cpp.
QSqlError::QSqlError | ( | const QSqlError & | other | ) |
QSqlError::~QSqlError | ( | ) |
Destroys the object and frees any allocated resources.
Definition at line 136 of file qsqlerror.cpp.
QString QSqlError::databaseText | ( | ) | const |
Returns the text of the error as reported by the database.
This may contain database-specific descriptions; it may be empty.
Definition at line 169 of file qsqlerror.cpp.
Referenced by QSQLiteDriver::beginTransaction(), QSQLiteDriver::commitTransaction(), operator<<(), QSQLiteDriver::rollbackTransaction(), and setDatabaseText().
QString QSqlError::driverText | ( | ) | const |
Returns the text of the error as reported by the driver.
This may contain database-specific descriptions. It may also be empty.
Definition at line 146 of file qsqlerror.cpp.
Referenced by operator<<(), and setDriverText().
bool QSqlError::isValid | ( | ) | const |
Returns true if an error is set, otherwise false.
Example:
Definition at line 254 of file qsqlerror.cpp.
Referenced by QSqlTableModel::select(), and QSqlQueryModel::setQuery().
int QSqlError::number | ( | ) | const |
Returns the database-specific error number, or -1 if it cannot be determined.
Definition at line 214 of file qsqlerror.cpp.
Referenced by operator<<(), and setNumber().
void QSqlError::setDatabaseText | ( | const QString & | databaseText | ) |
Sets the database error text to the value of databaseText.
Definition at line 180 of file qsqlerror.cpp.
void QSqlError::setDriverText | ( | const QString & | driverText | ) |
Sets the driver error text to the value of driverText.
Definition at line 157 of file qsqlerror.cpp.
void QSqlError::setNumber | ( | int | number | ) |
Sets the database-specific error number to number.
Definition at line 225 of file qsqlerror.cpp.
void QSqlError::setType | ( | ErrorType | type | ) |
Sets the error type to the value of type.
Definition at line 202 of file qsqlerror.cpp.
QString QSqlError::text | ( | ) | const |
This is a convenience function that returns databaseText() and driverText() concatenated into a single string.
Definition at line 237 of file qsqlerror.cpp.
Referenced by QSqlDatabasePrivate::database(), and qmlsqldatabase_executeSql().
QSqlError::ErrorType QSqlError::type | ( | ) | const |
Returns the error type, or -1 if the type cannot be determined.
Definition at line 191 of file qsqlerror.cpp.
Referenced by setType().
|
private |
Definition at line 91 of file qsqlerror.h.
Referenced by databaseText(), operator=(), setDatabaseText(), and text().
|
private |
Definition at line 90 of file qsqlerror.h.
Referenced by driverText(), operator=(), setDriverText(), and text().
|
private |
Definition at line 93 of file qsqlerror.h.
Referenced by number(), operator=(), and setNumber().
|
private |
Definition at line 92 of file qsqlerror.h.
Referenced by isValid(), operator=(), setType(), and type().