/*************************************************************************** * * * begin : 14 Nov 2003 * * copyright : (C) 2003 by Samokhvalov Anton :) * * * ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #ifndef __exceptions__h__6h45h6437bdgh #define __exceptions__h__6h45h6437bdgh #include class Exception { public: Exception( const QString& err, bool fatal_ = true ): error( err ), fatal( fatal_ ) { } QString getErrorMessage() const { return error; } bool isFatal() const { return fatal; } private: QString error; bool fatal; }; class FatalException: public Exception { public: FatalException( const QString& err ): Exception( i18n("fatal error: ") + err, true ) { } }; class NonfatalException: public Exception { public: NonfatalException( const QString& err ): Exception( i18n("non fatal error: ") + err, false ) { } }; class FileException: public NonfatalException { public: FileException( const QString& err ): NonfatalException( i18n("file exception: ") + err ) { } }; class FileNotFound: public FileException { public: FileNotFound( const QString& fname ): FileException( i18n("file ") + fname + i18n(" not found") ) { } }; class BadPath: public FileException { public: BadPath( const QString& path ): FileException( (path == "")?i18n("empty path"):(i18n("bad path ") + path) ) { } }; class DatabaseException: public FatalException { public: DatabaseException( const QString& error ): FatalException( i18n("database exception: ") + error ) { } }; #define Assert( a, b ) do { if( a ) { b; }; } while( false ); #endif