• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepimlibs API Reference
  • KDE Home
  • Contact Us
 

akonadi

  • sources
  • kde-4.12
  • kdepimlibs
  • akonadi
exception.cpp
1 /*
2  Copyright (c) 2009 Volker Krause <vkrause@kde.org>
3 
4  This library is free software; you can redistribute it and/or modify it
5  under the terms of the GNU Library General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or (at your
7  option) any later version.
8 
9  This library is distributed in the hope that it will be useful, but WITHOUT
10  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12  License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to the
16  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  02110-1301, USA.
18 */
19 
20 #include "exception.h"
21 
22 #include <KDebug>
23 #include <QString>
24 
25 #include <memory>
26 
27 using namespace Akonadi;
28 
29 class Exception::Private
30 {
31  public:
32  QByteArray what;
33  QByteArray assembledWhat;
34 };
35 
36 Exception::Exception(const char* what) throw() :
37  d( 0 )
38 {
39  try {
40  std::auto_ptr<Private> nd( new Private );
41  nd->what = what;
42  d = nd.release();
43  } catch ( ... ) {}
44 }
45 
46 Exception::Exception(const QByteArray& what) throw() :
47  d( 0 )
48 {
49  try {
50  std::auto_ptr<Private> nd( new Private );
51  nd->what = what;
52  d = nd.release();
53  } catch ( ... ) {}
54 }
55 
56 Exception::Exception(const QString& what) throw() :
57  d( 0 )
58 {
59  try {
60  std::auto_ptr<Private> nd( new Private );
61  nd->what = what.toUtf8();
62  d = nd.release();
63  } catch ( ... ) {}
64 }
65 
66 Exception::Exception(const Akonadi::Exception& other) throw() :
67  std::exception( other ), d( 0 )
68 {
69  if ( !other.d )
70  return;
71  try {
72  std::auto_ptr<Private> nd( new Private( *other.d ) );
73  d = nd.release();
74  } catch ( ... ) {}
75 }
76 
77 Exception::~Exception() throw()
78 {
79  delete d;
80 }
81 
82 QByteArray Exception::type() const throw()
83 {
84  static const char mytype[] = "Akonadi::Exception";
85  try {
86  return QByteArray::fromRawData( "Akonadi::Exception", sizeof(mytype) - 1 );
87  } catch ( ... ) {
88  return QByteArray();
89  }
90 }
91 
92 const char* Exception::what() const throw()
93 {
94  static const char fallback[] = "<some exception was thrown during construction: message lost>";
95  if ( !d )
96  return fallback;
97  if ( d->assembledWhat.isEmpty() )
98  try {
99  d->assembledWhat = QByteArray( type() + ": " + d->what );
100  } catch ( ... ) {
101  return "caught some exception while assembling Akonadi::Exception::what() return value";
102  }
103  return d->assembledWhat.constData();
104 }
105 
106 #define AKONADI_EXCEPTION_IMPLEMENT_TRIVIAL_INSTANCE( classname ) \
107  Akonadi::classname::~classname() throw() {} \
108  QByteArray Akonadi::classname::type() const throw() { \
109  static const char mytype[] = "Akonadi::" #classname ; \
110  try { \
111  return QByteArray::fromRawData( mytype, sizeof(mytype)-1 ); \
112  } catch ( ... ) { \
113  return QByteArray(); \
114  } \
115  }
116 
117 AKONADI_EXCEPTION_IMPLEMENT_TRIVIAL_INSTANCE( PayloadException )
118 
119 #undef AKONADI_EXCEPTION_IMPLEMENT_TRIVIAL_INSTANCE
Akonadi::Exception::Exception
Exception(const char *what)
Creates a new exception with the error message what.
Definition: exception.cpp:36
Akonadi::Exception::type
virtual QByteArray type() const
Returns the type of this exception.
Definition: exception.cpp:82
Akonadi::Exception::~Exception
virtual ~Exception()
Destructor.
Definition: exception.cpp:77
Akonadi::Exception
Base class for exceptions used by the Akonadi library.
Definition: exception.h:35
Akonadi::Exception::what
const char * what() const
Returns the error message associated with this exception.
Definition: exception.cpp:92
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:00:27 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

akonadi

Skip menu "akonadi"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • Modules
  • Related Pages

kdepimlibs API Reference

Skip menu "kdepimlibs API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kldap
  • kmbox
  • kmime
  • kpimidentities
  • kpimtextedit
  • kresources
  • ktnef
  • kxmlrpcclient
  • microblog

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal