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.cpp
85 lines (67 loc) · 1.75 KB
/
exception.cpp
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
74
75
76
77
78
79
80
81
82
83
84
#include "exception.h"
#include "defaults.h"
using namespace QtDataSync;
Exception::Exception(const QString &setupName, const QString &message) :
QException{},
_setupName{setupName},
_message{message}
{}
Exception::Exception(const Defaults &defaults, const QString &message) :
Exception{defaults.setupName(), message}
{}
Exception::Exception(const Exception * const other) : //MAJOR use normal copy ctr instead
QException{},
_setupName{other->_setupName},
_message{other->_message}
{}
QByteArray Exception::className() const noexcept
{
return QTDATASYNC_EXCEPTION_NAME(Exception);
}
QString Exception::setupName() const
{
return _setupName;
}
QString Exception::message() const
{
return _message;
}
QString Exception::qWhat() const
{
return QStringLiteral("Message: %1"
"\n\tException-Type: %2"
"\n\tSetup: %3")
.arg(_message, QString::fromUtf8(className()), _setupName);
}
const char *Exception::what() const noexcept
{
if(_qWhat.isEmpty())
_qWhat = qWhat().toUtf8();
return _qWhat.constData();
}
void Exception::raise() const
{
throw (*this);
}
QException *Exception::clone() const
{
return new Exception(this);
}
SetupDoesNotExistException::SetupDoesNotExistException(const QString &setupName) :
Exception{setupName, QStringLiteral("The requested setup does not exist! Create it with Setup::create")}
{}
SetupDoesNotExistException::SetupDoesNotExistException(const SetupDoesNotExistException * const other) :
Exception{other}
{}
QByteArray SetupDoesNotExistException::className() const noexcept
{
return QTDATASYNC_EXCEPTION_NAME(SetupDoesNotExistException);
}
void SetupDoesNotExistException::raise() const
{
throw (*this);
}
QException *SetupDoesNotExistException::clone() const
{
return new SetupDoesNotExistException(this);
}