libkcal

exceptions.cpp
1/*
2 This file is part of libkcal.
3
4 Copyright (c) 2001 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#include <tdelocale.h>
23
24#include "calformat.h"
25#include "exceptions.h"
26
27using namespace KCal;
28
29Exception::Exception( const TQString &message )
30{
31 mMessage = message;
32}
33
34Exception::~Exception()
35{
36}
37
39{
40 if ( mMessage.isEmpty() ) {
41 return i18n( "%1 Error" ).arg( CalFormat::application() );
42 } else {
43 return mMessage;
44 }
45}
46
47
48ErrorFormat::ErrorFormat( ErrorCodeFormat code, const TQString &message )
49 : Exception( message )
50{
51 mCode = code;
52}
53
55{
56 TQString message = "";
57
58 switch ( mCode ) {
59 case LoadError:
60 message = i18n( "Load Error" );
61 break;
62 case SaveError:
63 message = i18n( "Save Error" );
64 break;
65 case ParseErrorIcal:
66 message = i18n( "Parse Error in libical" );
67 break;
68 case ParseErrorKcal:
69 message = i18n( "Parse Error in libkcal" );
70 break;
71 case NoCalendar:
72 message = i18n( "No calendar component found." );
73 break;
74 case CalVersion1:
75 message = i18n( "vCalendar Version 1.0 detected." );
76 break;
77 case CalVersion2:
78 message = i18n( "iCalendar Version 2.0 detected." );
79 break;
81 message = i18n( "Unknown calendar format detected." );
82 break;
83 case Restriction:
84 message = i18n( "Restriction violation" );
85 break;
86 case NoWritableFound:
87 message = i18n( "No writable resource found" );
88 break;
89 case UserCancel:
90 // no real error; the user canceled the operation
91 break;
92 }
93
94 if ( !mMessage.isEmpty() ) {
95 message += ": " + mMessage;
96 }
97
98 return message;
99}
100
102{
103 return mCode;
104}
static const TQString & application()
Return the application name used in unique IDs and error messages.
Definition: calformat.h:85
ErrorFormat(ErrorCodeFormat code, const TQString &message=TQString())
Create format error exception.
Definition: exceptions.cpp:48
ErrorCodeFormat
The different types of Calendar format errors.
Definition: exceptions.h:70
@ Restriction
Restriction violation.
Definition: exceptions.h:79
@ NoCalendar
No calendar component found.
Definition: exceptions.h:75
@ LoadError
Load error.
Definition: exceptions.h:71
@ CalVersion1
vCalendar v1.0 detected
Definition: exceptions.h:76
@ ParseErrorIcal
Parse error in libical.
Definition: exceptions.h:73
@ NoWritableFound
No writable resource is available.
Definition: exceptions.h:80
@ ParseErrorKcal
Parse error in libkcal.
Definition: exceptions.h:74
@ CalVersion2
iCalendar v2.0 detected
Definition: exceptions.h:77
@ SaveError
Save error.
Definition: exceptions.h:72
@ CalVersionUnknown
Unknown calendar format detected.
Definition: exceptions.h:78
@ UserCancel
User canceled the operation.
Definition: exceptions.h:81
TQString message()
Return format error message.
Definition: exceptions.cpp:54
ErrorCodeFormat errorCode()
Return format error code.
Definition: exceptions.cpp:101
KOrganizer exceptions base class.
Definition: exceptions.h:40
virtual TQString message()
Return descriptive message of exception.
Definition: exceptions.cpp:38
Namespace KCal is for global classes, objects and/or functions in libkcal.
Definition: alarm.h:38