accounts-qt: Accounts/error.h Source File

accounts-qt 1.12

- Main Page
- Related Pages
- Classes
- Files

- File List

error.h
1 /*
2 * This file is part of libaccounts-qt
3 *
4 * Copyright (C) 2011 Nokia Corporation.
5 *
6 * Contact: Alberto Mardegan <alberto.mardegan@nokia.com>
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public License
10 * version 2.1 as published by the Free Software Foundation.
11 *
12 * This library is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA
21 */
27 #ifndef ACCOUNTS_ERROR_H
28 #define ACCOUNTS_ERROR_H
29
30 #include <QMetaType>
31 #include <QString>
32
33 #include <Accounts/accountscommon.h>
34
35 extern "C"
36 {
37 typedef struct _GError GError;
38 }
39
40 namespace Accounts {
41
42 class ACCOUNTS_EXPORT Error
43 {
44 public:
48 enum ErrorType {
49 NoError = 0,
50 Unknown,
51 Database,
52 Deleted,
54 DatabaseLocked,
55 AccountNotFound,
56 };
57
61 Error(): m_type(NoError), m_message(QString()) { registerType(); }
62
67 Error(const Error &src):
68 m_type(src.type()), m_message(src.message()) {}
69
75 Error(ErrorType type, const QString &message = QString()):
76 m_type(type), m_message(message)
77 { registerType(); }
78
83 Error &operator=(const Error &src)
84 { m_type = src.type(); m_message = src.message(); return *this; }
85
89 virtual ~Error() {}
90
94 ErrorType type() const { return m_type; }
95
99 QString message() const { return m_message; }
100
101 private:
102 // Don't include in docs: \cond
103 friend class Account;
104 friend class Manager;
105 Error(const GError *error);
106
107 inline void registerType();
108 // \endcond
109
110 private:
111 // Don't include private data in docs: \cond
112 ErrorType m_type;
113 QString m_message;
114 // \endcond
115 };
116
117 } //namespace
118
119 Q_DECLARE_METATYPE(Accounts::Error)
120
121 void Accounts::Error::registerType()
122 {
123 qRegisterMetaType<Accounts::Error>("Accounts::Error");
124 }
125
126 #endif // ACCOUNTS_ERROR_H
Accounts::Error::~Error
virtual ~Error()
Destructor.
Definition: error.h:89
Accounts::Manager
Manager of accounts, services and providers.
Definition: manager.h:51
Accounts::Error::ErrorType
ErrorType
Error codes for all the accounts errors.
Definition: error.h:48
Accounts::Error::type
ErrorType type() const
Definition: error.h:94
Accounts::Error::Error
Error(const Error &src)
Copy constructor.
Definition: error.h:67
Accounts::Error::Database
Definition: error.h:51
Accounts::Error::operator=
Error & operator=(const Error &src)
Assignment operator.
Definition: error.h:83
Accounts::Error::Error
Error()
Basic constructor.
Definition: error.h:61
Accounts::Error
Base object definition for accounts error handling.
Definition: error.h:42
Accounts::Error::message
QString message() const
Definition: error.h:99
Accounts::Error::DatabaseLocked
Definition: error.h:54
Accounts::Error::AccountNotFound
Definition: error.h:55
Accounts::Error::Error
Error(ErrorType type, const QString &message=QString())
Constructor.
Definition: error.h:75