/** @file * $Source: /home/cvsmanager/yoda/event/Exception.h,v $ * $Id: Exception.h,v 2.0 2004/09/21 20:49:57 kusanagi Exp $ * $Author: kusanagi $ * * Header file for the exceptions of Pamela. */ #ifndef EXCEPTION_H #define EXCEPTION_H #include #include #include "SubPacket.h" using namespace std; namespace pamela { class Exception: public exception { private: protected: const char *message; char buff [100]; public: Exception(const char *msg = "message"): message(msg){ } virtual ~Exception () throw(){ } virtual const char* print () const throw () { return message; } }; class UnidentifiedPacketException: public Exception { private: UINT8 pktId; public: UnidentifiedPacketException::UnidentifiedPacketException(UINT8 id): Exception("Unidentified PacketType - Id: ") { pktId = id; } UnidentifiedPacketException::~UnidentifiedPacketException () throw(){ } const char* UnidentifiedPacketException::print () const throw () { sprintf((char*)buff," %s 0x%x", message, pktId); return buff; } }; class WrongCRCException: public Exception { public: WrongCRCException::WrongCRCException(char* msg): Exception(msg) {} WrongCRCException::~WrongCRCException () throw(){ } const char* WrongCRCException::print () const throw () { return message; } }; class WrongCRCHeaderException: public Exception { public: WrongCRCHeaderException::WrongCRCHeaderException(): Exception() {} WrongCRCHeaderException::~WrongCRCHeaderException () throw(){ } const char* WrongCRCHeaderException::print () const throw () { return "CRC Header Exception"; } }; class LengthException: public Exception { public: LengthException::LengthException(char* msg): Exception(msg) { } LengthException::~LengthException () throw(){ } const char* LengthException::print () const throw () { return message; } }; class NotExistingAlgorithmException: public Exception { public: NotExistingAlgorithmException::NotExistingAlgorithmException(const char *msg): Exception(msg) { } NotExistingAlgorithmException::~NotExistingAlgorithmException () throw(){ } const char* NotExistingAlgorithmException::print () const throw () { return strcat("\n No way to read events of type ", message); } }; class NotExistingCounterException: public Exception { public: NotExistingCounterException::NotExistingCounterException(const char *msg): Exception(msg) { } NotExistingCounterException::~NotExistingCounterException () throw(){ } const char* NotExistingCounterException::print () const throw () { return strcat("\n No counter of type ", message); } }; } #endif /* EXCEPTION_H */