error.h
/*
* This file is part of libaccounts-qt
*
* Copyright (C) 2011 Nokia Corporation.
* Copyright (C) 2012-2016 Canonical Ltd.
*
* Contact: Alberto Mardegan <alberto.mardegan@canonical.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* version 2.1 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*/
#ifndef ACCOUNTS_ERROR_H
#define ACCOUNTS_ERROR_H
#include <QMetaType>
#include <QString>
#include <Accounts/accountscommon.h>
extern "C"
{
typedef struct _GError GError;
}
namespace Accounts {
class ACCOUNTS_EXPORT Error
{
public:
enum ErrorType {
NoError = 0,
Unknown,
Database,
Deleted,
DatabaseLocked,
AccountNotFound,
};
Error(): m_type(NoError), m_message(QString()) { registerType(); }
Error(const Error &src):
m_type(src.type()), m_message(src.message()) {}
Error(ErrorType type, const QString &message = QString()):
m_type(type), m_message(message)
{ registerType(); }
Error &operator=(const Error &src)
{ m_type = src.type(); m_message = src.message(); return *this; }
virtual ~Error() {}
ErrorType type() const { return m_type; }
QString message() const { return m_message; }
private:
// Don't include in docs: \cond
friend class Account;
friend class Manager;
Error(const GError *error);
inline void registerType();
// \endcond
private:
// Don't include private data in docs: \cond
ErrorType m_type;
QString m_message;
// \endcond
};
} //namespace
Q_DECLARE_METATYPE(Accounts::Error)
void Accounts::Error::registerType()
{
qRegisterMetaType<Accounts::Error>("Accounts::Error");
}
#endif // ACCOUNTS_ERROR_H
Accounts::Error::message
QString message() const
Definition: error.h:100
Accounts::Error::ErrorType
ErrorType
Definition: error.h:49
Accounts::Error::Error
Error(const Error &src)
Copy constructor.
Definition: error.h:68
Accounts::Error::type
ErrorType type() const
Definition: error.h:95
Accounts::Error::Database
@ Database
Definition: error.h:52
Accounts::Manager
Manager of accounts, services and providers.
Definition: manager.h:51
Accounts::Error
Base object definition for accounts error handling.
Definition: error.h:43
Accounts::Error::DatabaseLocked
@ DatabaseLocked
Definition: error.h:55
Accounts::Error::operator=
Error & operator=(const Error &src)
Assignment operator.
Definition: error.h:84
Accounts::Error::Error
Error()
Basic constructor.
Definition: error.h:62
Accounts::Error::Error
Error(ErrorType type, const QString &message=QString())
Constructor.
Definition: error.h:76
Accounts::Error::~Error
virtual ~Error()
Destructor.
Definition: error.h:90
Accounts::Error::AccountNotFound
@ AccountNotFound
Definition: error.h:56