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