exception.cpp
1/***************************************************************************
2 * This file is part of the KDE project
3 * copyright (C) 2005 by Sebastian Sauer (mail@dipe.org)
4 * copyright (C) 2005 by Tobi Krebs (tobi.krebs@gmail.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public License
15 * along with this program; see the file COPYING. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 ***************************************************************************/
19
20#include "exception.h"
21
22#include <kdebug.h>
23
24using namespace KoMacro;
25
26namespace KoMacro {
27
32 class Exception::Private
33 {
34 public:
35
37 const TQString errormessage;
38
40 TQString tracemessages;
41
45 Private(const TQString& errormessage)
46 : errormessage(errormessage)
47 {
48 }
49
50 };
51
52}
53
54//constructor
55Exception::Exception(const TQString& errormessage)
56 : d( new Private(errormessage) ) // create the private d-pointer instance.
57{
58 //debuging infos
59 kdDebug() << TQString("Exception errormessage=\"%1\"").arg(errormessage) << endl;
60}
61
62//copy constructor
64 : d( new Private( e.errorMessage() ) )
65{
66 d->tracemessages = e.traceMessages();
67}
68
69//deconstructor
71{
72 delete d;
73}
74
75//get d-pointer errormessage
76const TQString Exception::errorMessage() const
77{
78 return d->errormessage;
79}
80
81//get d-pointer tracemessages
82const TQString Exception::traceMessages() const
83{
84 return d->tracemessages;
85}
86
87//add a Qstring to d-pointer tracemessages
88void Exception::addTraceMessage(const TQString& tracemessage)
89{
90 //no tracemessages till now
91 if(d->tracemessages.isEmpty())
92 d->tracemessages = tracemessage;
93 //append to existing ones
94 else
95 d->tracemessages += "\n" + tracemessage;
96}
97
Base Exception class.
Definition exception.h:35
void addTraceMessage(const TQString &tracemessage)
Add the message tracemessage to the list of traces.
Definition exception.cpp:88
virtual ~Exception()
Destructor.
Definition exception.cpp:70
const TQString errorMessage() const
Definition exception.cpp:76
const TQString traceMessages() const
Definition exception.cpp:82
Exception(const TQString &errormessage)
Constructor.
Definition exception.cpp:55