--- yoda/event/Exception.h 2004/07/06 12:20:23 1.1.1.1 +++ yoda/event/Exception.h 2005/01/11 14:58:20 2.2 @@ -1,20 +1,78 @@ /** @file - * $Source: /home/cvspamela/yoda/event/Exception.h,v $ - * $Id: Exception.h,v 1.6 2004/03/16 10:18:28 nagni Exp $ - * $Author: nagni $ + * $Source: /home/cvsmanager/yoda/event/Exception.h,v $ + * $Id: Exception.h,v 2.1 2004/12/03 22:04:04 kusanagi Exp $ + * $Author: kusanagi $ * * Header file for the exceptions of Pamela. */ +#ifndef EXCEPTION_H +#define EXCEPTION_H #include -#include +#include +#include "SubPacket.h" +using namespace std; namespace pamela { - class Exception: public std::exception { + + class Exception: public exception { + private: - std::string Name; + + protected: + const char *message; + char buff [100]; public: - Exception(std::string name): Name(name) {} + Exception(const char *msg = "message"): message(msg){ } virtual ~Exception () throw(){ } - virtual const char* what () const throw () { return Name.c_str(); } + 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(const char* msg): Exception(msg) {} + WrongCRCException::~WrongCRCException () throw(){ } + }; + + class WrongCRCHeaderException: public Exception { + public: + WrongCRCHeaderException::WrongCRCHeaderException(const char* msg): Exception(msg) {} + WrongCRCHeaderException::~WrongCRCHeaderException () throw(){ } }; + + + class LengthException: public Exception { + public: + LengthException::LengthException(const char* msg): Exception(msg) { } + LengthException::~LengthException () throw(){ } + }; + + + class NotExistingAlgorithmException: public Exception { + public: + NotExistingAlgorithmException::NotExistingAlgorithmException(const char *msg): Exception(msg) { } + NotExistingAlgorithmException::~NotExistingAlgorithmException () throw(){ } + }; + + class NotExistingCounterException: public Exception { + public: + NotExistingCounterException::NotExistingCounterException(const char *msg): Exception(msg) { } + NotExistingCounterException::~NotExistingCounterException () throw(){ } + }; + } +#endif /* EXCEPTION_H */