00001 #ifndef LCIO_EXCEPTION_H 00002 #define LCIO_EXCEPTION_H 1 00003 00004 #include <string> 00005 #include <exception> 00006 00007 // define some exceptions similar to the ones used in hep.lcd.io 00008 // the exceptions should be part of the corresponding namespace 00009 // even though they are not defined in the package (subdirectory) 00010 // as these hold interfaces (abstract base classes) only .... 00011 // hmmmm - does this make sence ? 00012 00013 namespace EVENT { 00014 00015 /**Base exception class for LCIO - all other exceptions extend this. 00016 * @author gaede 00017 * @version Apr 30, 2003 00018 */ 00019 00020 class Exception : public std::exception { 00021 00022 00023 protected: 00024 std::string message ; 00025 00026 Exception(){ /*no_op*/ ; } 00027 00028 public: 00029 virtual ~Exception() throw() { /*no_op*/; } 00030 00031 Exception( const std::string& text ){ 00032 message = "lcio::Exception: " + text ; 00033 } 00034 00035 virtual const char* what() const throw() { return message.c_str() ; } 00036 00037 }; 00038 00039 /**EventException used for errors accessing the event data. 00040 * @author gaede 00041 * @version Apr 30, 2003 00042 */ 00043 class EventException : public Exception{ 00044 00045 protected: 00046 EventException() { /*no_op*/ ; } 00047 public: 00048 virtual ~EventException() throw() { /*no_op*/; } 00049 00050 EventException( std::string text ){ 00051 message = "lcio::EventException: " + text ; 00052 } 00053 }; 00054 00055 /**EventException used for data not available. 00056 * @author gaede 00057 * @version Jun 5, 2003 00058 */ 00059 class DataNotAvailableException : public EventException{ 00060 00061 public: 00062 virtual ~DataNotAvailableException() throw() { /*no_op*/; } 00063 00064 DataNotAvailableException( std::string text ) { 00065 message = "lcio::DataNotAvailableException: " + text ; 00066 } 00067 }; 00068 00069 /**EventException used for signaling a 'read only exception'. 00070 * @author gaede 00071 * @version Jun 5, 2003 00072 */ 00073 class ReadOnlyException : public EventException{ 00074 00075 public: 00076 virtual ~ReadOnlyException() throw() { /*no_op*/; } 00077 00078 ReadOnlyException( std::string text ){ 00079 message = "lcio::ReadOnlyException: " + text ; 00080 } 00081 }; 00082 00083 } // namespace 00084 00085 namespace IO { 00086 00087 /**IOException used for reading/writing errors. 00088 * @author gaede 00089 * @version Apr 30, 2003 00090 */ 00091 class IOException : public EVENT::Exception{ 00092 00093 protected: 00094 IOException() { /* no_op */ } ; 00095 00096 public: 00097 IOException( std::string text ){ 00098 message = "lcio::IOException: " + text ; 00099 } 00100 }; 00101 00102 // --- used only internally - switched back to null pointer at EOF ------ 00103 /**EndOfDataException for signaling the end of a data stream. 00104 * @author gaede 00105 * @version Jun 5, 2003 00106 */ 00107 class EndOfDataException : public IOException{ 00108 public: 00109 virtual ~EndOfDataException() throw() { /*no_op*/; } 00110 00111 EndOfDataException( std::string text ){ 00112 message = "lcio::EndOfDataException: " + text ; 00113 } 00114 }; 00115 00116 } // namespace 00117 #endif /* ifndef LCIO_EXCEPTION_H */
1.3.9.1