Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qsqlerror.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qsqlerror.h"
5#include "qdebug.h"
6
8
9using namespace Qt::StringLiterals;
10
11#ifndef QT_NO_DEBUG_STREAM
13{
14 QDebugStateSaver saver(dbg);
15 dbg.nospace();
16 dbg << "QSqlError(" << s.nativeErrorCode() << ", " << s.driverText()
17 << ", " << s.databaseText() << ')';
18 return dbg;
19}
20#endif
21
31
32
92QSqlError::QSqlError(const QString &driverText, const QString &databaseText,
93 ErrorType type, const QString &code)
94 : d(new QSqlErrorPrivate)
95{
96 d->driverError = driverText;
97 d->databaseError = databaseText;
98 d->errorType = type;
99 d->errorCode = code;
100}
101
102
107 = default;
108
114 = default;
115
116
123{
124 return (d->errorType == other.d->errorType &&
125 d->errorCode == other.d->errorCode);
126}
127
128
135{
136 return (d->errorType != other.d->errorType ||
137 d->errorCode != other.d->errorCode);
138}
139
140
146 = default;
147
155{
156 return d->driverError;
157}
158
167{
168 return d->databaseError;
169}
170
176{
177 return d->errorType;
178}
179
189{
190 return d->errorCode;
191}
192
201{
203 if (!d->databaseError.isEmpty() && !d->driverError.isEmpty() && !d->databaseError.endsWith(u'\n'))
204 result += u' ';
205 result += d->driverError;
206 return result;
207}
208
218{
219 return d->errorType != NoError;
220}
221
\inmodule QtCore
\inmodule QtCore
\inmodule QtCore
Definition qshareddata.h:19
QSqlError::ErrorType errorType
Definition qsqlerror.cpp:27
QString driverError
Definition qsqlerror.cpp:25
QString databaseError
Definition qsqlerror.cpp:26
The QSqlError class provides SQL database error information.
Definition qsqlerror.h:17
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 dat...
Definition qsqlerror.cpp:92
bool operator!=(const QSqlError &other) const
Compare the other error's type() and nativeErrorCode() to this error and returns true if it is not eq...
QSqlError & operator=(const QSqlError &other)
Move-assigns other to this QSqlError instance.
ErrorType type() const
Returns the error type, or -1 if the type cannot be determined.
~QSqlError()
Destroys the object and frees any allocated resources.
QString nativeErrorCode() const
Returns the database-specific error code, or an empty string if it cannot be determined.
bool operator==(const QSqlError &other) const
Compare the other error's type() and nativeErrorCode() to this error and returns true,...
QString databaseText() const
Returns the text of the error as reported by the database.
QString text() const
This is a convenience function that returns databaseText() and driverText() concatenated into a singl...
QString driverText() const
Returns the text of the error as reported by the driver.
bool isValid() const
Returns true if an error is set, otherwise false.
ErrorType
This enum type describes the context in which the error occurred, e.g., a connection error,...
Definition qsqlerror.h:19
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
Definition qstring.h:192
bool endsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string ends with s; otherwise returns false.
Definition qstring.cpp:5506
Combined button and popup list for selecting options.
GLenum type
GLdouble s
[6]
Definition qopenglext.h:235
GLuint64EXT * result
[6]
#define QT_DEFINE_QESDP_SPECIALIZATION_DTOR(Class)
QDebug operator<<(QDebug dbg, const QSqlError &s)
Definition qsqlerror.cpp:12
QSharedPointer< T > other(t)
[5]