summaryrefslogtreecommitdiffabout
path: root/libkcal/exceptions.cpp
authorzautrix <zautrix>2004-06-26 19:01:18 (UTC)
committer zautrix <zautrix>2004-06-26 19:01:18 (UTC)
commitb9aad1f15dc600e4dbe4c62d3fcced6363188ba3 (patch) (unidiff)
tree2c3d4004fb21c72cba65793859f9bcd8ffd3a49c /libkcal/exceptions.cpp
downloadkdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.zip
kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.tar.gz
kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.tar.bz2
Initial revision
Diffstat (limited to 'libkcal/exceptions.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/exceptions.cpp90
1 files changed, 90 insertions, 0 deletions
diff --git a/libkcal/exceptions.cpp b/libkcal/exceptions.cpp
new file mode 100644
index 0000000..bc298f9
--- a/dev/null
+++ b/libkcal/exceptions.cpp
@@ -0,0 +1,90 @@
1/*
2 This file is part of libkcal.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library 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
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19*/
20
21#include <klocale.h>
22
23#include "calformat.h"
24#include "exceptions.h"
25
26using namespace KCal;
27
28Exception::Exception(const QString &message)
29{
30 mMessage = message;
31}
32
33Exception::~Exception()
34{
35}
36
37QString Exception::message()
38{
39 if (mMessage.isEmpty()) return i18n("%1 Error").arg(CalFormat::application());
40 else return mMessage;
41}
42
43
44ErrorFormat::ErrorFormat(ErrorCodeFormat code,const QString &message) :
45 Exception(message)
46{
47 mCode = code;
48}
49
50QString ErrorFormat::message()
51{
52 QString message = "";
53
54 switch (mCode) {
55 case LoadError:
56 message = i18n("Load Error");
57 break;
58 case SaveError:
59 message = i18n("Save Error");
60 break;
61 case ParseErrorIcal:
62 message = i18n("Parse Error in libical");
63 break;
64 case ParseErrorKcal:
65 message = i18n("Parse Error in libkcal");
66 break;
67 case NoCalendar:
68 message = i18n("No calendar component found.");
69 break;
70 case CalVersion1:
71 message = i18n("vCalendar Version 1.0 detected.");
72 break;
73 case CalVersion2:
74 message = i18n("iCalendar Version 2.0 detected.");
75 break;
76 case Restriction:
77 message = i18n("Restriction violation");
78 default:
79 break;
80 }
81
82 if (!mMessage.isEmpty()) message += ": " + mMessage;
83
84 return message;
85}
86
87ErrorFormat::ErrorCodeFormat ErrorFormat::errorCode()
88{
89 return mCode;
90}