1 ////////////////////////////////////////////////////////////////////////////////
3 // Author: Artur Szostak
4 // Email: artur@alice.phy.uct.ac.za | artursz@iafrica.com
6 ////////////////////////////////////////////////////////////////////////////////
11 #include "BasicTypes.hpp"
19 class Error : public std::exception
24 virtual ~Error() throw() {};
26 /* Should return a human readable string containing a description of the
29 virtual const char* Message() const throw() = 0;
31 /* Returns an error code describing the error. The error code should be
32 unique to the entire system
34 virtual Int ErrorCode() const throw() = 0;
36 virtual const char* what() const throw()
41 /* Define the << operator for streams to be able to do something like:
44 cout << myerror << endl;
46 friend std::ostream& operator << (std::ostream& os, const dHLT::Error& error)
48 os << error.Message();
54 class OutOfMemory : public Error
57 virtual const char* Message() const throw();
58 virtual Int ErrorCode() const throw();
62 /* When one needs to indicate that no more memory is available one should use the
63 ThrowOutOfMemory method rather than explicitly using the code
65 This is because the ThrowOutOfMemory routine throws a preallocated object so
66 we are safe from having to allocate more (nonexistant) memory.
68 void ThrowOutOfMemory() throw (OutOfMemory);
71 // Error code declarations.
74 OUT_OF_MEMORY = 0x10000001
80 #endif // dHLT_ERROR_HPP