libkcal
exceptions.cpp
Go to the documentation of this file.00001 /* 00002 This file is part of libkcal. 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 */ 00021 00022 #include <klocale.h> 00023 00024 #include "calformat.h" 00025 #include "exceptions.h" 00026 00027 using namespace KCal; 00028 00029 Exception::Exception(const QString &message) 00030 { 00031 mMessage = message; 00032 } 00033 00034 Exception::~Exception() 00035 { 00036 } 00037 00038 QString Exception::message() 00039 { 00040 if (mMessage.isEmpty()) return i18n("%1 Error").arg(CalFormat::application()); 00041 else return mMessage; 00042 } 00043 00044 00045 ErrorFormat::ErrorFormat(ErrorCodeFormat code,const QString &message) : 00046 Exception(message) 00047 { 00048 mCode = code; 00049 } 00050 00051 QString ErrorFormat::message() 00052 { 00053 QString message = ""; 00054 00055 switch (mCode) { 00056 case LoadError: 00057 message = i18n("Load Error"); 00058 break; 00059 case SaveError: 00060 message = i18n("Save Error"); 00061 break; 00062 case ParseErrorIcal: 00063 message = i18n("Parse Error in libical"); 00064 break; 00065 case ParseErrorKcal: 00066 message = i18n("Parse Error in libkcal"); 00067 break; 00068 case NoCalendar: 00069 message = i18n("No calendar component found."); 00070 break; 00071 case CalVersion1: 00072 message = i18n("vCalendar Version 1.0 detected."); 00073 break; 00074 case CalVersion2: 00075 message = i18n("iCalendar Version 2.0 detected."); 00076 break; 00077 case Restriction: 00078 message = i18n("Restriction violation"); 00079 default: 00080 break; 00081 } 00082 00083 if (!mMessage.isEmpty()) message += ": " + mMessage; 00084 00085 return message; 00086 } 00087 00088 ErrorFormat::ErrorCodeFormat ErrorFormat::errorCode() 00089 { 00090 return mCode; 00091 }