1 |
/** @file |
/** @file |
2 |
* $Source: /home/cvsmanager/yoda/event/Exception.h,v $ |
* $Source: /home/cvsmanager/yoda/event/Exception.h,v $ |
3 |
* $Id: Exception.h,v 1.1.1.1 2004/07/06 12:20:23 kusanagi Exp $ |
* $Id: Exception.h,v 2.0 2004/09/21 20:49:57 kusanagi Exp $ |
4 |
* $Author: kusanagi $ |
* $Author: kusanagi $ |
5 |
* |
* |
6 |
* Header file for the exceptions of Pamela. |
* Header file for the exceptions of Pamela. |
7 |
*/ |
*/ |
8 |
|
#ifndef EXCEPTION_H |
9 |
|
#define EXCEPTION_H |
10 |
#include <exception> |
#include <exception> |
11 |
#include <string> |
#include <stdio.h> |
12 |
|
#include "SubPacket.h" |
13 |
|
|
14 |
|
using namespace std; |
15 |
namespace pamela { |
namespace pamela { |
16 |
class Exception: public std::exception { |
|
17 |
|
class Exception: public exception { |
18 |
|
|
19 |
private: |
private: |
20 |
std::string Name; |
|
21 |
|
protected: |
22 |
|
const char *message; |
23 |
|
char buff [100]; |
24 |
public: |
public: |
25 |
Exception(std::string name): Name(name) {} |
Exception(const char *msg = "message"): message(msg){ } |
26 |
virtual ~Exception () throw(){ } |
virtual ~Exception () throw(){ } |
27 |
virtual const char* what () const throw () { return Name.c_str(); } |
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 |
|
WrongCRCException::WrongCRCException(char* msg): Exception(msg) {} |
48 |
|
WrongCRCException::~WrongCRCException () throw(){ } |
49 |
|
const char* WrongCRCException::print () const throw () { |
50 |
|
return message; |
51 |
|
} |
52 |
|
}; |
53 |
|
|
54 |
|
class WrongCRCHeaderException: public Exception { |
55 |
|
public: |
56 |
|
WrongCRCHeaderException::WrongCRCHeaderException(): Exception() {} |
57 |
|
WrongCRCHeaderException::~WrongCRCHeaderException () throw(){ } |
58 |
|
const char* WrongCRCHeaderException::print () const throw () { |
59 |
|
return "CRC Header Exception"; |
60 |
|
} |
61 |
}; |
}; |
62 |
|
|
63 |
|
|
64 |
|
class LengthException: public Exception { |
65 |
|
public: |
66 |
|
LengthException::LengthException(char* msg): Exception(msg) { } |
67 |
|
LengthException::~LengthException () throw(){ } |
68 |
|
const char* LengthException::print () const throw () { |
69 |
|
return message; |
70 |
|
} |
71 |
|
}; |
72 |
|
|
73 |
|
|
74 |
|
class NotExistingAlgorithmException: public Exception { |
75 |
|
public: |
76 |
|
NotExistingAlgorithmException::NotExistingAlgorithmException(const char *msg): Exception(msg) { } |
77 |
|
NotExistingAlgorithmException::~NotExistingAlgorithmException () throw(){ } |
78 |
|
const char* NotExistingAlgorithmException::print () const throw () { |
79 |
|
return strcat("\n No way to read events of type ", message); |
80 |
|
} |
81 |
|
}; |
82 |
|
|
83 |
|
class NotExistingCounterException: public Exception { |
84 |
|
public: |
85 |
|
NotExistingCounterException::NotExistingCounterException(const char *msg): Exception(msg) { } |
86 |
|
NotExistingCounterException::~NotExistingCounterException () throw(){ } |
87 |
|
const char* NotExistingCounterException::print () const throw () { |
88 |
|
return strcat("\n No counter of type ", message); |
89 |
|
} |
90 |
|
}; |
91 |
|
|
92 |
} |
} |
93 |
|
#endif /* EXCEPTION_H */ |