1 |
pam-rm2 |
1.1 |
/** @file |
2 |
|
|
* $Source: /afs/ba.infn.it/user/pamela/src/CVS/yoda/event/Exception.h,v $ |
3 |
|
|
* $Id: Exception.h,v 6.0 2006/02/07 17:11:07 kusanagi Exp $ |
4 |
|
|
* $Author: kusanagi $ |
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 |
pam-rm2 |
1.2 |
NotFoundEnvironmentVarException(const char* msg): Exception(msg) {} |
36 |
|
|
~NotFoundEnvironmentVarException () throw(){ } |
37 |
pam-rm2 |
1.1 |
}; |
38 |
|
|
|
39 |
|
|
class UnidentifiedPacketException: public Exception { |
40 |
|
|
private: |
41 |
|
|
UINT8 pktId; |
42 |
|
|
public: |
43 |
pam-rm2 |
1.2 |
UnidentifiedPacketException(UINT8 id): |
44 |
pam-rm2 |
1.1 |
Exception("Unidentified PacketType - Id: ") { |
45 |
|
|
pktId = id; |
46 |
|
|
} |
47 |
pam-rm2 |
1.2 |
~UnidentifiedPacketException () throw(){ } |
48 |
|
|
const char* print () const throw () { |
49 |
pam-rm2 |
1.1 |
sprintf((char*)buff," %s 0x%x", message, pktId); |
50 |
|
|
return buff; |
51 |
|
|
} |
52 |
|
|
}; |
53 |
|
|
|
54 |
|
|
class WrongCRCException: public Exception { |
55 |
|
|
public: |
56 |
pam-rm2 |
1.2 |
WrongCRCException(const char* msg): Exception(msg) {} |
57 |
|
|
~WrongCRCException () throw(){ } |
58 |
pam-rm2 |
1.1 |
}; |
59 |
|
|
|
60 |
|
|
class WrongCRCHeaderException: public Exception { |
61 |
|
|
public: |
62 |
pam-rm2 |
1.2 |
WrongCRCHeaderException(const char* msg): Exception(msg) {} |
63 |
|
|
~WrongCRCHeaderException () throw(){ } |
64 |
pam-rm2 |
1.1 |
}; |
65 |
|
|
|
66 |
|
|
|
67 |
|
|
class LengthException: public Exception { |
68 |
|
|
public: |
69 |
pam-rm2 |
1.2 |
LengthException(const char* msg): Exception(msg) { } |
70 |
|
|
~LengthException () throw(){ } |
71 |
pam-rm2 |
1.1 |
}; |
72 |
|
|
|
73 |
|
|
|
74 |
|
|
class NotExistingAlgorithmException: public Exception { |
75 |
|
|
public: |
76 |
pam-rm2 |
1.2 |
NotExistingAlgorithmException(const char *msg): Exception(msg) { } |
77 |
|
|
~NotExistingAlgorithmException () throw(){ } |
78 |
pam-rm2 |
1.1 |
}; |
79 |
|
|
|
80 |
|
|
class NotExistingCounterException: public Exception { |
81 |
|
|
public: |
82 |
pam-rm2 |
1.2 |
NotExistingCounterException(const char *msg): Exception(msg) { } |
83 |
|
|
~NotExistingCounterException () throw(){ } |
84 |
pam-rm2 |
1.1 |
}; |
85 |
|
|
|
86 |
|
|
class BackwardCounterException: public Exception { |
87 |
|
|
public: |
88 |
pam-rm2 |
1.2 |
BackwardCounterException(const char *msg): Exception(msg) { } |
89 |
|
|
~BackwardCounterException () throw(){ } |
90 |
pam-rm2 |
1.1 |
}; |
91 |
|
|
} |
92 |
|
|
#endif /* EXCEPTION_H */ |