1/*
2 This file is part of the kcalcore 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 class.
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 Exception base class.
32
33 @author Cornelius Schumacher \<schumacher@kde.org\>
34*/
35
36#ifndef KCALCORE_EXCEPTIONS_H
37#define KCALCORE_EXCEPTIONS_H
38
39#include "kcalcore_export.h"
40
41#include <QtCore/QString>
42#include <QtCore/QStringList>
43
44namespace KCalCore {
45
46/**
47 Exception base class, currently used as a fancy kind of error code
48 and not as an C++ exception.
49*/
50class Exception
51{
52public:
53
54 /**
55 The different types of error codes
56 */
57 //KDAB_TODO: give decent names here
58 enum ErrorCode {
59 LoadError, /**< Load error */
60 SaveError, /**< Save error */
61 ParseErrorIcal, /**< Parse error in libical */
62 ParseErrorKcal, /**< Parse error in libkcal */
63 NoCalendar, /**< No calendar component found */
64 CalVersion1, /**< vCalendar v1.0 detected */
65 CalVersion2, /**< iCalendar v2.0 detected */
66 CalVersionUnknown, /**< Unknown calendar format detected */
67 Restriction, /**< Restriction violation */
68 UserCancel, /**< User canceled the operation */
69 NoWritableFound, /**< No writable resource is available */
70 SaveErrorOpenFile,
71 SaveErrorSaveFile,
72 LibICalError,
73 VersionPropertyMissing,
74 ExpectedCalVersion2,
75 ExpectedCalVersion2Unknown,
76 ParseErrorNotIncidence,
77 ParseErrorEmptyMessage,
78 ParseErrorUnableToParse,
79 ParseErrorMethodProperty
80 };
81
82 /**
83 Construct an exception.
84 @param code is the error code.
85 @param arguments is a list of arguments that can be passed
86 to an i18n engine to help build a descriptive message for the user, a common
87 argument is for example the filename where the error occurred.
88 */
89 explicit Exception(const ErrorCode code,
90 const QStringList &arguments = QStringList());
91
92 /**
93 Destructor.
94 */
95 virtual ~Exception();
96
97 /**
98 Returns the error code.
99 @return The ErrorCode for this exception.
100 */
101 virtual ErrorCode code() const;
102
103 /**
104 Returns the arguments.
105 @return A QStringList with the argument list for this exception.
106 */
107 virtual QStringList arguments() const;
108
109protected:
110 /**
111 The current exception code.
112 */
113 ErrorCode mCode;
114
115 /** Arguments to pass to i18n(). */
116 QStringList mArguments;
117
118private:
119 //@cond PRIVATE
120 Q_DISABLE_COPY(Exception)
121 class Private;
122 Private *const d;
123 //@endcond
124};
125
126} // namespace
127
128#endif
129