KCal Library
exceptions.cpp
Go to the documentation of this file.00001 /* 00002 This file is part of the kcal library. 00003 00004 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 00005 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Library General Public 00008 License as published by the Free Software Foundation; either 00009 version 2 of the License, or (at your option) any later version. 00010 00011 This library is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 Library General Public License for more details. 00015 00016 You should have received a copy of the GNU Library General Public License 00017 along with this library; see the file COPYING.LIB. If not, write to 00018 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00019 Boston, MA 02110-1301, USA. 00020 */ 00036 #include "exceptions.h" 00037 #include "calformat.h" 00038 00039 #include <klocale.h> 00040 00041 using namespace KCal; 00042 00043 Exception::Exception( const QString &message ) 00044 { 00045 mMessage = message; 00046 } 00047 00048 Exception::~Exception() 00049 { 00050 } 00051 00052 QString Exception::message() 00053 { 00054 if ( mMessage.isEmpty() ) { 00055 return i18n( "%1 Error", CalFormat::application() ); 00056 } else { 00057 return mMessage; 00058 } 00059 } 00060 00065 //@cond PRIVATE 00066 class KCal::ErrorFormat::Private 00067 { 00068 public: 00069 ErrorCodeFormat mCode; 00070 }; 00071 //@endcond 00072 00073 ErrorFormat::ErrorFormat( ErrorCodeFormat code, const QString &message ) 00074 : Exception( message ), d( new KCal::ErrorFormat::Private ) 00075 { 00076 d->mCode = code; 00077 } 00078 00079 ErrorFormat::~ErrorFormat() 00080 { 00081 delete d; 00082 } 00083 00084 QString ErrorFormat::message() 00085 { 00086 QString message = ""; 00087 00088 switch ( d->mCode ) { 00089 case LoadError: 00090 message = i18n( "Load Error" ); 00091 break; 00092 case SaveError: 00093 message = i18n( "Save Error" ); 00094 break; 00095 case ParseErrorIcal: 00096 message = i18n( "Parse Error in libical" ); 00097 break; 00098 case ParseErrorKcal: 00099 message = i18n( "Parse Error in libkcal" ); 00100 break; 00101 case NoCalendar: 00102 message = i18n( "No calendar component found." ); 00103 break; 00104 case CalVersion1: 00105 message = i18n( "vCalendar Version 1.0 detected." ); 00106 break; 00107 case CalVersion2: 00108 message = i18n( "iCalendar Version 2.0 detected." ); 00109 break; 00110 case CalVersionUnknown: 00111 message = i18n( "Unknown calendar format detected." ); 00112 break; 00113 case Restriction: 00114 message = i18n( "Restriction violation" ); 00115 break; 00116 } 00117 00118 if ( !mMessage.isEmpty() ) { 00119 message += ": " + mMessage; 00120 } 00121 00122 return message; 00123 } 00124 00125 ErrorFormat::ErrorCodeFormat ErrorFormat::errorCode() 00126 { 00127 return d->mCode; 00128 }