source: trunk/src/sql/kernel/qsqlerror.cpp@ 117

Last change on this file since 117 was 2, checked in by Dmitry A. Kuminov, 16 years ago

Initially imported qt-all-opensource-src-4.5.1 from Trolltech.

File size: 6.4 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4** Contact: Qt Software Information ([email protected])
5**
6** This file is part of the QtSql module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial Usage
10** Licensees holding valid Qt Commercial licenses may use this file in
11** accordance with the Qt Commercial License Agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and Nokia.
14**
15** GNU Lesser General Public License Usage
16** Alternatively, this file may be used under the terms of the GNU Lesser
17** General Public License version 2.1 as published by the Free Software
18** Foundation and appearing in the file LICENSE.LGPL included in the
19** packaging of this file. Please review the following information to
20** ensure the GNU Lesser General Public License version 2.1 requirements
21** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
22**
23** In addition, as a special exception, Nokia gives you certain
24** additional rights. These rights are described in the Nokia Qt LGPL
25** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
26** package.
27**
28** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you are unsure which license is appropriate for your use, please
37** contact the sales department at [email protected].
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42#include "qsqlerror.h"
43#include "qdebug.h"
44
45QT_BEGIN_NAMESPACE
46
47#ifndef QT_NO_DEBUG_STREAM
48QDebug operator<<(QDebug dbg, const QSqlError &s)
49{
50 dbg.nospace() << "QSqlError(" << s.number() << ", " << s.driverText() <<
51 ", " << s.databaseText() << ")";
52 return dbg.space();
53}
54#endif
55
56/*!
57 \class QSqlError
58 \brief The QSqlError class provides SQL database error information.
59
60 \ingroup database
61 \inmodule QtSql
62
63 A QSqlError object can provide database-specific error data,
64 including the driverText() and databaseText() messages (or both
65 concatenated together as text()), and the error number() and
66 type(). The functions all have setters so that you can create and
67 return QSqlError objects from your own classes, for example from
68 your own SQL drivers.
69
70 \sa QSqlDatabase::lastError(), QSqlQuery::lastError()
71*/
72
73/*!
74 \enum QSqlError::ErrorType
75
76 This enum type describes the context in which the error occurred, e.g., a connection error, a statement error, etc.
77
78 \value NoError No error occurred.
79 \value ConnectionError Connection error.
80 \value StatementError SQL statement syntax error.
81 \value TransactionError Transaction failed error.
82 \value UnknownError Unknown error.
83
84 \omitvalue None
85 \omitvalue Connection
86 \omitvalue Statement
87 \omitvalue Transaction
88 \omitvalue Unknown
89*/
90
91/*!
92 Constructs an error containing the driver error text \a
93 driverText, the database-specific error text \a databaseText, the
94 type \a type and the optional error number \a number.
95*/
96
97QSqlError::QSqlError(const QString& driverText, const QString& databaseText, ErrorType type,
98 int number)
99 : driverError(driverText), databaseError(databaseText), errorType(type), errorNumber(number)
100{
101}
102
103/*!
104 Creates a copy of \a other.
105*/
106QSqlError::QSqlError(const QSqlError& other)
107 : driverError(other.driverError), databaseError(other.databaseError),
108 errorType(other.errorType),
109 errorNumber(other.errorNumber)
110{
111}
112
113/*!
114 Assigns the \a other error's values to this error.
115*/
116
117QSqlError& QSqlError::operator=(const QSqlError& other)