akonadi
exception.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "exception.h"
00021
00022 #include <KDebug>
00023 #include <QString>
00024
00025 namespace Akonadi {
00026
00027 class Exception::Private
00028 {
00029 public:
00030 QByteArray what;
00031 QByteArray assembledWhat;
00032 };
00033
00034 Exception::Exception(const char* what) throw() :
00035 d( new Private )
00036 {
00037 d->what = what;
00038 }
00039
00040 Exception::Exception(const QByteArray& what) throw() :
00041 d( new Private )
00042 {
00043 d->what = what;
00044 }
00045
00046 Exception::Exception(const QString& what) throw() :
00047 d( new Private )
00048 {
00049 d->what = what.toUtf8();
00050 }
00051
00052 Exception::Exception(const Akonadi::Exception& other) throw() :
00053 std::exception( other ), d( new Private )
00054 {
00055 d->what = other.d->what;
00056 }
00057
00058 Exception::~Exception() throw()
00059 {
00060 delete d;
00061 }
00062
00063 QByteArray Exception::type() const throw()
00064 {
00065 return "Akonadi::Exception";
00066 }
00067
00068 const char* Exception::what() const throw()
00069 {
00070 d->assembledWhat = QByteArray( type() + ": " + d->what );
00071 return d->assembledWhat.constData();
00072 }
00073
00074 }