LCIO  02.17
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Exceptions.h
Go to the documentation of this file.
1 #ifndef LCIO_EXCEPTION_H
2 #define LCIO_EXCEPTION_H 1
3 
4 #include <string>
5 #include <exception>
6 #include <stdexcept>
7 
8 // define some exceptions similar to the ones used in hep.lcd.io
9 // the exceptions should be part of the corresponding namespace
10 // even though they are not defined in the package (subdirectory)
11 // as these hold interfaces (abstract base classes) only ....
12 // hmmmm - does this make sence ?
13 
14 namespace EVENT {
15 
21  class Exception : public std::exception {
22 
23 
24  protected:
26 
27  Exception(){ /*no_op*/ ; }
28 
29  public:
30  virtual ~Exception() { /*no_op*/; }
31 
32  Exception( const std::string& text ){
33  message = "lcio::Exception: " + text ;
34  }
35 
36  virtual const char* what() const noexcept { return message.c_str() ; }
37 
38  };
39 
44  class EventException : public Exception{
45 
46  protected:
47  EventException() { /*no_op*/ ; }
48  public:
49  virtual ~EventException() { /*no_op*/; }
50 
52  message = "lcio::EventException: " + text ;
53  }
54  };
55 
61 
62  public:
63  virtual ~DataNotAvailableException() { /*no_op*/; }
64 
66  message = "lcio::DataNotAvailableException: " + text ;
67  }
68  };
69 
75 
76  public:
77  virtual ~ReadOnlyException() { /*no_op*/; }
78 
80  message = "lcio::ReadOnlyException: " + text ;
81  }
82  };
83 
84 } // namespace
85 
86 namespace IO {
87 
92  class IOException : public EVENT::Exception{
93 
94  protected:
95  IOException() { /* no_op */ } ;
96 
97  public:
99  message = "lcio::IOException: " + text ;
100  }
101  };
102 
103  // --- used only internally - switched back to null pointer at EOF ------
109  public:
110  virtual ~EndOfDataException() { /*no_op*/; }
111 
113  message = "lcio::EndOfDataException: " + text ;
114  }
115  };
116 
117 } // namespace
118 #endif /* ifndef LCIO_EXCEPTION_H */
Base exception class for LCIO - all other exceptions extend this.
Definition: Exceptions.h:21
EventException(std::string text)
Definition: Exceptions.h:51
DataNotAvailableException(std::string text)
Definition: Exceptions.h:65
virtual ~EndOfDataException()
Definition: Exceptions.h:110
virtual ~EventException()
Definition: Exceptions.h:49
STL class.
EndOfDataException(std::string text)
Definition: Exceptions.h:112
virtual const char * what() const noexcept
Definition: Exceptions.h:36
EventException used for errors accessing the event data.
Definition: Exceptions.h:44
IOException used for reading/writing errors.
Definition: Exceptions.h:92
Exception(const std::string &text)
Definition: Exceptions.h:32
EventException used for data not available.
Definition: Exceptions.h:60
T c_str(T...args)
EndOfDataException for signaling the end of a data stream.
Definition: Exceptions.h:108
std::string message
Definition: Exceptions.h:25
IOException(std::string text)
Definition: Exceptions.h:98
ReadOnlyException(std::string text)
Definition: Exceptions.h:79
virtual ~Exception()
Definition: Exceptions.h:30
virtual ~ReadOnlyException()
Definition: Exceptions.h:77
EventException used for signaling a &#39;read only exception&#39;.
Definition: Exceptions.h:74