00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef INCLUDE_BASE_FATALEXCEPTION_H
00015 #define INCLUDE_BASE_FATALEXCEPTION_H
00016
00017 #include <iostream>
00018 #include <exception>
00019
00020 namespace base
00021 {
00022
00023
00024
00025 class FatalException : public std::exception
00026 {
00027 public:
00028
00029
00030
00031
00032 FatalException(const char *whichone) throw()
00033 : message(whichone) {}
00034
00035
00036
00037 virtual const char* what() const throw();
00038
00039 private:
00040 const char *message;
00041 };
00042
00043
00044
00045 static inline
00046 std::ostream& operator << (std::ostream& os,
00047 const FatalException& x)
00048 {
00049 return os << x.what();
00050 }
00051
00052 }
00053
00054
00055
00056
00057 #define FATAL(MSG) do { \
00058 std::cerr << "Fatal exception: " \
00059 << MSG << std::endl; \
00060 throw base::FatalException(MSG); \
00061 } while(0)
00062
00063 #endif // INCLUDE_BASE_FATAL_EXCEPTION