1/*
2 This file is part of the kcal library.
3
4 Copyright (c) 2001-2003 Cornelius Schumacher <schumacher@kde.org>
5
6 This library 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
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
15
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
20*/
21/**
22 @file
23 This file is part of the API for handling calendar data and
24 defines the Exception and ErrorFormat classes.
25
26 We don't use actual C++ exceptions right now. These classes are currently
27 returned by an error function; but we can build upon them, if/when we start
28 to use C++ exceptions.
29
30 @brief
31 Exceptions base class along with the Calendar ErrorFormat class.
32
33 @author Cornelius Schumacher \<schumacher@kde.org\>
34*/
35
36#ifndef KCAL_EXCEPTIONS_H
37#define KCAL_EXCEPTIONS_H
38
39#include <QtCore/QString>
40#include "kcal_export.h"
41
42namespace KCal {
43
44/**
45 Exceptions base class, currently used as a fancy kind of error code
46 and not as an C++ exception.
47*/
48class Exception
49{
50 public:
51 /**
52 Construct an exception with a descriptive message.
53 @param message is the message string.
54 */
55 explicit Exception( const QString &message = QString() );
56
57 /**
58 Destructor.
59 */
60 virtual ~Exception();
61
62 /**
63 Returns the exception message.
64 */
65 virtual QString message();
66
67 protected:
68 /** The current exception message. */
69 QString mMessage;
70
71 private:
72 //@cond PRIVATE
73 Q_DISABLE_COPY( Exception )
74 class Private;
75 Private *d;
76 //@endcond
77};
78
79/**
80 Calendar format related error class.
81*/
82class KCAL_DEPRECATED_EXPORT ErrorFormat : public Exception
83{
84 public:
85 /**
86 The different types of Calendar format errors.
87 */
88 enum ErrorCodeFormat {
89 LoadError, /**< Load error */
90 SaveError, /**< Save error */
91 ParseErrorIcal, /**< Parse error in libical */
92 ParseErrorKcal, /**< Parse error in libkcal */
93 NoCalendar, /**< No calendar component found */
94 CalVersion1, /**< vCalendar v1.0 detected */
95 CalVersion2, /**< iCalendar v2.0 detected */
96 CalVersionUnknown, /**< Unknown calendar format detected */
97 Restriction, /**< Restriction violation */
98 UserCancel, /**< User canceled the operation */
99 NoWritableFound /**< No writable resource is available. @since 4.5 */
100 };
101
102 /**
103 Creates a format error exception.
104
105 @param code is the exception #ErrorCodeFormat.
106 @param message is the exception message string.
107 */
108 explicit ErrorFormat( ErrorCodeFormat code,
109 const QString &message = QString() );
110
111 /**
112 Destructor.
113 */
114 ~ErrorFormat();
115
116 /**
117 Returns the format error message.
118 */
119 QString message();
120
121 /**
122 Returns the format error code.
123 */
124 ErrorCodeFormat errorCode();
125
126 private:
127 //@cond PRIVATE
128 Q_DISABLE_COPY( ErrorFormat )
129 class Private;
130 Private *const d;
131 //@endcond
132};
133
134}
135
136#endif
137