This repository was archived by the owner on Mar 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathexception.h
73 lines (57 loc) · 2.06 KB
/
exception.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#ifndef QTDATASYNC_EXCEPTION_H
#define QTDATASYNC_EXCEPTION_H
#include <QtCore/qexception.h>
#include "QtDataSync/qtdatasync_global.h"
namespace QtDataSync {
class Defaults;
//! The base class for all exceptions of QtDataSync
class Q_DATASYNC_EXPORT Exception : public QException
{
public:
//! Constructor for an exception from the given setup
Exception(const QString &setupName, const QString &message);
//! Constructor for an exception with the given defaults
Exception(const Defaults &defaults, const QString &message);
//! Returns the name of the exception
virtual QByteArray className() const noexcept;
//! Returns the name of the setup the exception was thrown from
QString setupName() const;
//! Returns the actual error message of the exception
QString message() const;
//! Like what, but returns a QString instead of a character array
virtual QString qWhat() const;
//! @inherit{QException::what}
virtual const char *what() const noexcept final; //mark virtual again for doxygen
//! @inherit{QException::raise}
virtual void raise() const override; //mark virtual again for doxygen
//! @inherit{QException::clone}
virtual QException *clone() const override; //mark virtual again for doxygen
protected:
//! @private
Exception(const Exception * const other);
//! @private
QString _setupName;
//! @private
QString _message;
//! @private
mutable QByteArray _qWhat;
};
//! An Exception thrown in case a class is trying to access a setup that does not exist
class Q_DATASYNC_EXPORT SetupDoesNotExistException : public Exception
{
public:
//! Constructor for an exception from the given setup
SetupDoesNotExistException(const QString &setupName);
QByteArray className() const noexcept override;
void raise() const override;
QException *clone() const override;
protected:
//! @private
SetupDoesNotExistException(const SetupDoesNotExistException * const other);
};
}
//! @private
#define __QTDATASYNC_EXCEPTION_NAME_IMPL(x) #x
//! @private
#define QTDATASYNC_EXCEPTION_NAME(x) "QtDataSync::" __QTDATASYNC_EXCEPTION_NAME_IMPL(x)
#endif // QTDATASYNC_EXCEPTION_H