Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00027 #ifndef ACCOUNTS_ERROR_H
00028 #define ACCOUNTS_ERROR_H
00029
00030 #include <QMetaType>
00031 #include <QString>
00032
00033 #include <Accounts/accountscommon.h>
00034
00035 extern "C"
00036 {
00037 typedef struct _GError GError;
00038 }
00039
00040 namespace Accounts {
00041
00046 class ACCOUNTS_EXPORT Error
00047 {
00048 public:
00052 enum ErrorType {
00053 NoError = 0,
00054 Unknown,
00055 Database,
00056 Deleted,
00058 DatabaseLocked,
00059 AccountNotFound,
00060 };
00061
00065 Error(): m_type(NoError), m_message(QString()) { registerType(); }
00066
00071 Error(const Error &src):
00072 m_type(src.type()), m_message(src.message()) {}
00073
00079 Error(ErrorType type, const QString &message = QString()):
00080 m_type(type), m_message(message)
00081 { registerType(); }
00082
00087 Error &operator=(const Error &src)
00088 { m_type = src.type(); m_message = src.message(); return *this; }
00089
00093 virtual ~Error() {}
00094
00098 ErrorType type() const { return m_type; }
00099
00103 QString message() const { return m_message; }
00104
00105 private:
00106
00107 friend class Account;
00108 friend class Manager;
00109 Error(const GError *error);
00110
00111 void registerType()
00112 { qRegisterMetaType<Error>("Accounts::Error"); }
00113
00114
00115 private:
00116
00117 ErrorType m_type;
00118 QString m_message;
00119
00120 };
00121
00122 }
00123
00124 Q_DECLARE_METATYPE(Accounts::Error)
00125
00126 #endif // ACCOUNTS_ERROR_H