1 |
kusanagi |
1.1 |
/** @file |
2 |
kusanagi |
2.0 |
* $Source: /home/cvsmanager/yoda/event/Exception.h,v $ |
3 |
kusanagi |
2.2 |
* $Id: Exception.h,v 2.1 2004/12/03 22:04:04 kusanagi Exp $ |
4 |
kusanagi |
2.0 |
* $Author: kusanagi $ |
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 |
|
|
#include "SubPacket.h" |
13 |
kusanagi |
1.1 |
|
14 |
kusanagi |
2.1 |
using namespace std; |
15 |
kusanagi |
1.1 |
namespace pamela { |
16 |
kusanagi |
2.1 |
|
17 |
|
|
class Exception: public exception { |
18 |
|
|
|
19 |
kusanagi |
1.1 |
private: |
20 |
kusanagi |
2.1 |
|
21 |
|
|
protected: |
22 |
|
|
const char *message; |
23 |
|
|
char buff [100]; |
24 |
kusanagi |
1.1 |
public: |
25 |
kusanagi |
2.1 |
Exception(const char *msg = "message"): message(msg){ } |
26 |
kusanagi |
1.1 |
virtual ~Exception () throw(){ } |
27 |
kusanagi |
2.1 |
virtual const char* print () const throw () { return message; } |
28 |
|
|
}; |
29 |
|
|
|
30 |
|
|
class UnidentifiedPacketException: public Exception { |
31 |
|
|
private: |
32 |
|
|
UINT8 pktId; |
33 |
|
|
public: |
34 |
|
|
UnidentifiedPacketException::UnidentifiedPacketException(UINT8 id): |
35 |
|
|
Exception("Unidentified PacketType - Id: ") { |
36 |
|
|
pktId = id; |
37 |
|
|
} |
38 |
|
|
UnidentifiedPacketException::~UnidentifiedPacketException () throw(){ } |
39 |
|
|
const char* UnidentifiedPacketException::print () const throw () { |
40 |
|
|
sprintf((char*)buff," %s 0x%x", message, pktId); |
41 |
|
|
return buff; |
42 |
|
|
} |
43 |
|
|
}; |
44 |
|
|
|
45 |
|
|
class WrongCRCException: public Exception { |
46 |
|
|
public: |
47 |
kusanagi |
2.2 |
WrongCRCException::WrongCRCException(const char* msg): Exception(msg) {} |
48 |
kusanagi |
2.1 |
WrongCRCException::~WrongCRCException () throw(){ } |
49 |
|
|
}; |
50 |
|
|
|
51 |
|
|
class WrongCRCHeaderException: public Exception { |
52 |
|
|
public: |
53 |
kusanagi |
2.2 |
WrongCRCHeaderException::WrongCRCHeaderException(const char* msg): Exception(msg) {} |
54 |
kusanagi |
2.1 |
WrongCRCHeaderException::~WrongCRCHeaderException () throw(){ } |
55 |
kusanagi |
1.1 |
}; |
56 |
kusanagi |
2.1 |
|
57 |
|
|
|
58 |
|
|
class LengthException: public Exception { |
59 |
|
|
public: |
60 |
kusanagi |
2.2 |
LengthException::LengthException(const char* msg): Exception(msg) { } |
61 |
kusanagi |
2.1 |
LengthException::~LengthException () throw(){ } |
62 |
|
|
}; |
63 |
|
|
|
64 |
|
|
|
65 |
|
|
class NotExistingAlgorithmException: public Exception { |
66 |
|
|
public: |
67 |
|
|
NotExistingAlgorithmException::NotExistingAlgorithmException(const char *msg): Exception(msg) { } |
68 |
|
|
NotExistingAlgorithmException::~NotExistingAlgorithmException () throw(){ } |
69 |
|
|
}; |
70 |
|
|
|
71 |
|
|
class NotExistingCounterException: public Exception { |
72 |
|
|
public: |
73 |
|
|
NotExistingCounterException::NotExistingCounterException(const char *msg): Exception(msg) { } |
74 |
|
|
NotExistingCounterException::~NotExistingCounterException () throw(){ } |
75 |
|
|
}; |
76 |
|
|
|
77 |
kusanagi |
1.1 |
} |
78 |
kusanagi |
2.1 |
#endif /* EXCEPTION_H */ |