/
exception.cpp
54 lines (43 loc) · 1011 Bytes
/
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
#include "exception.h"
namespace ts
{
Exception::Exception()
: m_type( Unknown ),
m_description( "" )
{}
Exception::Exception( Type new_type, const QString& new_desc )
: m_type( new_type ),
m_description( new_desc )
{
qDebug( "%s raised.", dumpObject().toUtf8().data() );
}
Exception::Exception( const Exception& x )
{
m_type = x.m_type;
m_description = x.m_description;
}
Exception::~Exception()
{
}
Exception& Exception::operator=( const Exception& x )
{
m_type = x.m_type;
m_description = x.m_description;
return *this;
}
QString Exception::dumpObject() const
{
QString sType;
switch( m_type )
{
case Runtime:
sType = "Runtime";
break;
default:
sType = "Unknown";
}
QString sRet = "";
sRet.sprintf( "Exception (%s) '%s'", sType.toUtf8().data(), m_description.toUtf8().data() );
return sRet;
}
} // namespace ts