1 |
kusanagi |
1.1 |
/** @file |
2 |
kusanagi |
2.0 |
* $Source: /home/cvsmanager/yoda/event/Exception.h,v $ |
3 |
kusanagi |
5.1 |
* $Id: Exception.h,v 5.0 2005/08/29 09:45:48 Maurizio Nagni Exp $ |
4 |
|
|
* $Author: Maurizio Nagni $ |
5 |
kusanagi |
1.1 |
* |
6 |
|
|
* Header file for the exceptions of Pamela. |
7 |
|
|
*/ |
8 |
kusanagi |
2.1 |
#ifndef EXCEPTION_H |
9 |
|
|
#define EXCEPTION_H |
10 |
kusanagi |
1.1 |
#include <exception> |
11 |
kusanagi |
2.1 |
#include <stdio.h> |
12 |
kusanagi |
5.1 |
|
13 |
|
|
#define UINT32 unsigned int |
14 |
|
|
#define UINT16 unsigned short |
15 |
|
|
#define UINT8 unsigned char |
16 |
kusanagi |
1.1 |
|
17 |
kusanagi |
2.1 |
using namespace std; |
18 |
kusanagi |
1.1 |
namespace pamela { |
19 |
kusanagi |
2.1 |
|
20 |
|
|
class Exception: public exception { |
21 |
|
|
|
22 |
kusanagi |
1.1 |
private: |
23 |
kusanagi |
2.1 |
|
24 |
|
|
protected: |
25 |
|
|
const char *message; |
26 |
|
|
char buff [100]; |
27 |
kusanagi |
1.1 |
public: |
28 |
kusanagi |
2.1 |
Exception(const char *msg = "message"): message(msg){ } |
29 |
kusanagi |
1.1 |
virtual ~Exception () throw(){ } |
30 |
kusanagi |
2.1 |
virtual const char* print () const throw () { return message; } |
31 |
|
|
}; |
32 |
|
|
|
33 |
kusanagi |
2.3 |
class NotFoundEnvironmentVarException: public Exception { |
34 |
|
|
public: |
35 |
|
|
NotFoundEnvironmentVarException::NotFoundEnvironmentVarException(const char* msg): Exception(msg) {} |
36 |
|
|
NotFoundEnvironmentVarException::~NotFoundEnvironmentVarException () throw(){ } |
37 |
|
|
}; |
38 |
|
|
|
39 |
kusanagi |
2.1 |
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 |
kusanagi |
2.2 |
WrongCRCException::WrongCRCException(const char* msg): Exception(msg) {} |
57 |
kusanagi |
2.1 |
WrongCRCException::~WrongCRCException () throw(){ } |
58 |
|
|
}; |
59 |
|
|
|
60 |
|
|
class WrongCRCHeaderException: public Exception { |
61 |
|
|
public: |
62 |
kusanagi |
2.2 |
WrongCRCHeaderException::WrongCRCHeaderException(const char* msg): Exception(msg) {} |
63 |
kusanagi |
2.1 |
WrongCRCHeaderException::~WrongCRCHeaderException () throw(){ } |
64 |
kusanagi |
1.1 |
}; |
65 |
kusanagi |
2.1 |
|
66 |
|
|
|
67 |
|
|
class LengthException: public Exception { |
68 |
|
|
public: |
69 |
kusanagi |
2.2 |
LengthException::LengthException(const char* msg): Exception(msg) { } |
70 |
kusanagi |
2.1 |
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 |
kusanagi |
4.5 |
class BackwardCounterException: public Exception { |
87 |
|
|
public: |
88 |
|
|
BackwardCounterException::BackwardCounterException(const char *msg): Exception(msg) { } |
89 |
|
|
BackwardCounterException::~BackwardCounterException () throw(){ } |
90 |
|
|
}; |
91 |
kusanagi |
1.1 |
} |
92 |
kusanagi |
2.1 |
#endif /* EXCEPTION_H */ |