exceptions.cpp
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 <tdelocale.h> 00023 00024 #include "calformat.h" 00025 #include "exceptions.h" 00026 00027 using namespace KCal; 00028 00029 Exception::Exception( const TQString &message ) 00030 { 00031 mMessage = message; 00032 } 00033 00034 Exception::~Exception() 00035 { 00036 } 00037 00038 TQString Exception::message() 00039 { 00040 if ( mMessage.isEmpty() ) { 00041 return i18n( "%1 Error" ).arg( CalFormat::application() ); 00042 } else { 00043 return mMessage; 00044 } 00045 } 00046 00047 00048 ErrorFormat::ErrorFormat( ErrorCodeFormat code, const TQString &message ) 00049 : Exception( message ) 00050 { 00051 mCode = code; 00052 } 00053 00054 TQString ErrorFormat::message() 00055 { 00056 TQString message = ""; 00057 00058 switch ( mCode ) { 00059 case LoadError: 00060 message = i18n( "Load Error" ); 00061 break; 00062 case SaveError: 00063 message = i18n( "Save Error" ); 00064 break; 00065 case ParseErrorIcal: 00066 message = i18n( "Parse Error in libical" ); 00067 break; 00068 case ParseErrorKcal: 00069 message = i18n( "Parse Error in libkcal" ); 00070 break; 00071 case NoCalendar: 00072 message = i18n( "No calendar component found." ); 00073 break; 00074 case CalVersion1: 00075 message = i18n( "vCalendar Version 1.0 detected." ); 00076 break; 00077 case CalVersion2: 00078 message = i18n( "iCalendar Version 2.0 detected." ); 00079 break; 00080 case CalVersionUnknown: 00081 message = i18n( "Unknown calendar format detected." ); 00082 break; 00083 case Restriction: 00084 message = i18n( "Restriction violation" ); 00085 break; 00086 case NoWritableFound: 00087 message = i18n( "No writable resource found" ); 00088 break; 00089 case UserCancel: 00090 // no real error; the user canceled the operation 00091 break; 00092 } 00093 00094 if ( !mMessage.isEmpty() ) { 00095 message += ": " + mMessage; 00096 } 00097 00098 return message; 00099 } 00100 00101 ErrorFormat::ErrorCodeFormat ErrorFormat::errorCode() 00102 { 00103 return mCode; 00104 }