libkcal Library API Documentation

exceptions.cpp

00001 /*
00002     This file is part of libkcal.
00003     Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
00004 
00005     This library is free software; you can redistribute it and/or
00006     modify it under the terms of the GNU Library General Public
00007     License as published by the Free Software Foundation; either
00008     version 2 of the License, or (at your option) any later version.
00009 
00010     This library is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013     Library General Public License for more details.
00014 
00015     You should have received a copy of the GNU Library General Public License
00016     along with this library; see the file COPYING.LIB.  If not, write to
00017     the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00018     Boston, MA 02111-1307, USA.
00019 */
00020 
00021 #include <klocale.h>
00022 
00023 #include "calformat.h"
00024 #include "exceptions.h"
00025 
00026 using namespace KCal;
00027 
00028 Exception::Exception(const QString &message)
00029 {
00030   mMessage = message;
00031 }
00032 
00033 Exception::~Exception()
00034 {
00035 }
00036 
00037 QString Exception::message()
00038 {
00039   if (mMessage.isEmpty()) return i18n("%1 Error").arg(CalFormat::application());
00040   else return mMessage;
00041 }
00042     
00043 
00044 ErrorFormat::ErrorFormat(ErrorCodeFormat code,const QString &message) :
00045   Exception(message)
00046 {
00047   mCode = code;
00048 }
00049     
00050 QString ErrorFormat::message()
00051 {
00052   QString message = "";
00053 
00054   switch (mCode) {
00055     case LoadError:
00056       message = i18n("Load Error");
00057       break;
00058     case SaveError:
00059       message = i18n("Save Error");
00060       break;
00061     case ParseErrorIcal:
00062       message = i18n("Parse Error in libical");
00063       break;
00064     case ParseErrorKcal:
00065       message = i18n("Parse Error in libkcal");
00066       break;
00067     case NoCalendar:
00068       message = i18n("No calendar component found.");
00069       break;
00070     case CalVersion1:
00071       message = i18n("vCalendar Version 1.0 detected.");
00072       break;
00073     case CalVersion2:
00074       message = i18n("iCalendar Version 2.0 detected.");
00075       break;
00076     case Restriction:
00077       message = i18n("Restriction violation");
00078     default:
00079       break;
00080   }
00081   
00082   if (!mMessage.isEmpty()) message += ": " + mMessage;
00083   
00084   return message;
00085 }
00086 
00087 ErrorFormat::ErrorCodeFormat ErrorFormat::errorCode()
00088 {
00089   return mCode;
00090 }
KDE Logo
This file is part of the documentation for libkcal Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat May 1 11:36:21 2004 by doxygen 1.2.15 written by Dimitri van Heesch, © 1997-2003