![]() |
Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
|
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.g., a connection error, a statement error, etc. More... | |
Public Member Functions | |
QSqlError (const QString &driverText=QString(), const QString &databaseText=QString(), ErrorType type=NoError, const QString &errorCode=QString()) | |
Constructs an error containing the driver error text driverText, the database-specific error text databaseText, the type type and the error code code. | |
QSqlError (const QSqlError &other) | |
Creates a copy of other. | |
QSqlError (QSqlError &&other) noexcept=default | |
Move-constructs a QSqlError instance, making it point at the same object that other was pointing to. | |
QSqlError & | operator= (const QSqlError &other) |
Move-assigns other to this QSqlError instance. | |
~QSqlError () | |
Destroys the object and frees any allocated resources. | |
bool | operator== (const QSqlError &other) const |
Compare the other error's type() and nativeErrorCode() to this error and returns true , if it equal. | |
bool | operator!= (const QSqlError &other) const |
Compare the other error's type() and nativeErrorCode() to this error and returns true if it is not equal. | |
void | swap (QSqlError &other) noexcept |
\memberswap{error} | |
QString | driverText () const |
Returns the text of the error as reported by the driver. | |
QString | databaseText () const |
Returns the text of the error as reported by the database. | |
ErrorType | type () const |
Returns the error type, or -1 if the type cannot be determined. | |
QString | nativeErrorCode () const |
Returns the database-specific error code, or an empty string if it cannot be determined. | |
QString | text () const |
This is a convenience function that returns databaseText() and driverText() concatenated into a single string. | |
bool | isValid () const |
Returns true if an error is set, otherwise false. | |
The QSqlError class provides SQL database error information.
\inmodule QtSql
A QSqlError object can provide database-specific error data, including the driverText() and databaseText() messages (or both concatenated together as text()), and the nativeErrorCode() and type().
Definition at line 16 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.
\value NoError No error occurred. \value ConnectionError Connection error. \value StatementError SQL statement syntax error. \value TransactionError Transaction failed error. \value UnknownError Unknown error.
Enumerator | |
---|---|
NoError | |
ConnectionError | |
StatementError | |
TransactionError | |
UnknownError |
Definition at line 19 of file qsqlerror.h.
QSqlError::QSqlError | ( | const QString & | driverText = QString(), |
const QString & | databaseText = QString(), | ||
ErrorType | type = NoError, | ||
const QString & | errorCode = QString() ) |
Constructs an error containing the driver error text driverText, the database-specific error text databaseText, the type type and the error code code.
Definition at line 90 of file qsqlerror.cpp.
|
default |
Creates a copy of other.
|
defaultnoexcept |
Move-constructs a QSqlError instance, making it point at the same object that other was pointing to.
|
default |
Destroys the object and frees any allocated resources.
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 164 of file qsqlerror.cpp.
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 152 of file qsqlerror.cpp.
bool QSqlError::isValid | ( | ) | const |
Returns true
if an error is set, otherwise false.
Example:
Definition at line 215 of file qsqlerror.cpp.
QString QSqlError::nativeErrorCode | ( | ) | const |
Returns the database-specific error code, or an empty string if it cannot be determined.
; is used as separator between the error codes. Definition at line 186 of file qsqlerror.cpp.
bool QSqlError::operator!= | ( | const QSqlError & | other | ) | const |
Compare the other error's type() and nativeErrorCode() to this error and returns true
if it is not equal.
Definition at line 132 of file qsqlerror.cpp.
Move-assigns other to this QSqlError instance.
Assigns the other error's values to this error.
bool QSqlError::operator== | ( | const QSqlError & | other | ) | const |
Compare the other error's type() and nativeErrorCode() to this error and returns true
, if it equal.
Definition at line 120 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 198 of file qsqlerror.cpp.
QSqlError::ErrorType QSqlError::type | ( | ) | const |
Returns the error type, or -1 if the type cannot be determined.
Definition at line 173 of file qsqlerror.cpp.