| 1 |
cafagna |
1.1 |
/** @file
|
| 2 |
|
|
* $Source: /afs/ba.infn.it/user/pamela/src/CVS/quicklook/OrbitalRate/inc/Exception.h,v $
|
| 3 |
|
|
* $Id: Exception.h,v 1.1 2006/12/05 19:49:14 pam-rm2 Exp $
|
| 4 |
|
|
* $Author: pam-rm2 $
|
| 5 |
|
|
*
|
| 6 |
|
|
* Header file for the exceptions of Pamela.
|
| 7 |
|
|
*/
|
| 8 |
|
|
#ifndef EXCEPTION_H
|
| 9 |
|
|
#define EXCEPTION_H
|
| 10 |
|
|
#include <exception>
|
| 11 |
|
|
#include <stdio.h>
|
| 12 |
|
|
|
| 13 |
|
|
#define UINT32 unsigned int
|
| 14 |
|
|
#define UINT16 unsigned short
|
| 15 |
|
|
#define UINT8 unsigned char
|
| 16 |
|
|
|
| 17 |
|
|
using namespace std;
|
| 18 |
|
|
namespace pamela {
|
| 19 |
|
|
|
| 20 |
|
|
class Exception: public exception {
|
| 21 |
|
|
|
| 22 |
|
|
private:
|
| 23 |
|
|
|
| 24 |
|
|
protected:
|
| 25 |
|
|
const char *message;
|
| 26 |
|
|
char buff [100];
|
| 27 |
|
|
public:
|
| 28 |
|
|
Exception(const char *msg = "message"): message(msg){ }
|
| 29 |
|
|
virtual ~Exception () throw(){ }
|
| 30 |
|
|
virtual const char* print () const throw () { return message; }
|
| 31 |
|
|
};
|
| 32 |
|
|
|
| 33 |
|
|
class NotFoundEnvironmentVarException: public Exception {
|
| 34 |
|
|
public:
|
| 35 |
|
|
NotFoundEnvironmentVarException::NotFoundEnvironmentVarException(const char* msg): Exception(msg) {}
|
| 36 |
|
|
NotFoundEnvironmentVarException::~NotFoundEnvironmentVarException () throw(){ }
|
| 37 |
|
|
};
|
| 38 |
|
|
|
| 39 |
|
|
class UnidentifiedPacketException: public Exception {
|
| 40 |
|
|
private:
|
| 41 |
|
|
UINT8 pktId;
|
| 42 |
|
|
public:
|
| 43 |
|
|
UnidentifiedPacketException::UnidentifiedPacketException(UINT8 id):
|
| 44 |
|
|
Exception("Unidentified PacketType - Id: ") {
|
| 45 |
|
|
pktId = id;
|
| 46 |
|
|
}
|
| 47 |
|
|
UnidentifiedPacketException::~UnidentifiedPacketException () throw(){ }
|
| 48 |
|
|
const char* UnidentifiedPacketException::print () const throw () {
|
| 49 |
|
|
sprintf((char*)buff," %s 0x%x", message, pktId);
|
| 50 |
|
|
return buff;
|
| 51 |
|
|
}
|
| 52 |
|
|
};
|
| 53 |
|
|
|
| 54 |
|
|
class WrongCRCException: public Exception {
|
| 55 |
|
|
public:
|
| 56 |
|
|
WrongCRCException::WrongCRCException(const char* msg): Exception(msg) {}
|
| 57 |
|
|
WrongCRCException::~WrongCRCException () throw(){ }
|
| 58 |
|
|
};
|
| 59 |
|
|
|
| 60 |
|
|
class WrongCRCHeaderException: public Exception {
|
| 61 |
|
|
public:
|
| 62 |
|
|
WrongCRCHeaderException::WrongCRCHeaderException(const char* msg): Exception(msg) {}
|
| 63 |
|
|
WrongCRCHeaderException::~WrongCRCHeaderException () throw(){ }
|
| 64 |
|
|
};
|
| 65 |
|
|
|
| 66 |
|
|
|
| 67 |
|
|
class LengthException: public Exception {
|
| 68 |
|
|
public:
|
| 69 |
|
|
LengthException::LengthException(const char* msg): Exception(msg) { }
|
| 70 |
|
|
LengthException::~LengthException () throw(){ }
|
| 71 |
|
|
};
|
| 72 |
|
|
|
| 73 |
|
|
|
| 74 |
|
|
class NotExistingAlgorithmException: public Exception {
|
| 75 |
|
|
public:
|
| 76 |
|
|
NotExistingAlgorithmException::NotExistingAlgorithmException(const char *msg): Exception(msg) { }
|
| 77 |
|
|
NotExistingAlgorithmException::~NotExistingAlgorithmException () throw(){ }
|
| 78 |
|
|
};
|
| 79 |
|
|
|
| 80 |
|
|
class NotExistingCounterException: public Exception {
|
| 81 |
|
|
public:
|
| 82 |
|
|
NotExistingCounterException::NotExistingCounterException(const char *msg): Exception(msg) { }
|
| 83 |
|
|
NotExistingCounterException::~NotExistingCounterException () throw(){ }
|
| 84 |
|
|
};
|
| 85 |
|
|
|
| 86 |
|
|
class BackwardCounterException: public Exception {
|
| 87 |
|
|
public:
|
| 88 |
|
|
BackwardCounterException::BackwardCounterException(const char *msg): Exception(msg) { }
|
| 89 |
|
|
BackwardCounterException::~BackwardCounterException () throw(){ }
|
| 90 |
|
|
};
|
| 91 |
|
|
}
|
| 92 |
|
|
#endif /* EXCEPTION_H */
|