![]() |
Qt 6.x
The Qt SDK
|
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 |
Swaps error other with this 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 92 of file qsqlerror.cpp.
References d.
|
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 166 of file qsqlerror.cpp.
References QSqlErrorPrivate::databaseError.
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 154 of file qsqlerror.cpp.
References QSqlErrorPrivate::driverError.
bool QSqlError::isValid | ( | ) | const |
Returns true
if an error is set, otherwise false.
Example:
Definition at line 217 of file qsqlerror.cpp.
References QSqlErrorPrivate::errorType, and NoError.
Referenced by checkSqlQueryModel(), QSqlQuery::exec(), and MyModel::fetchModel().
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 188 of file qsqlerror.cpp.
References QSqlErrorPrivate::errorCode.
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 134 of file qsqlerror.cpp.
References QSqlErrorPrivate::errorCode, QSqlErrorPrivate::errorType, and other().
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 122 of file qsqlerror.cpp.
References QSqlErrorPrivate::errorCode, QSqlErrorPrivate::errorType, and other().
|
inlinenoexcept |
Swaps error other with this error.
This operation is very fast and never fails.
Definition at line 39 of file qsqlerror.h.
QString QSqlError::text | ( | ) | const |
This is a convenience function that returns databaseText() and driverText() concatenated into a single string.
Definition at line 200 of file qsqlerror.cpp.
References QSqlErrorPrivate::databaseError, QSqlErrorPrivate::driverError, QString::endsWith(), and QString::isEmpty().
QSqlError::ErrorType QSqlError::type | ( | ) | const |
Returns the error type, or -1 if the type cannot be determined.
Definition at line 175 of file qsqlerror.cpp.
References QSqlErrorPrivate::errorType.
Referenced by QOCIResult::execBatch().