Exceptions.h
Go to the documentation of this file.
1 /**
2  Wire Cell code may throw exceptions.
3 
4  The core Wire Cell code should only throw WireCell::Exception (or
5  a subclass).
6 
7  Boost exceptions are used to allow the programmer to provide
8  dynamic information about an error and to collect file name and
9  line number.
10 
11  Exceptions should be thrown something like:
12 
13  if (omg) {
14  THROW(ValueError() << errmsg{"I didn't expect that"});
15  }
16  */
17 
18 #ifndef WIRECELL_EXCEPTIONS
19 #define WIRECELL_EXCEPTIONS
20 
21 #include <boost/exception/all.hpp>
22 #include <exception>
23 #include <string>
24 
25 #define THROW(e) BOOST_THROW_EXCEPTION(e)
26 #define errstr(e) boost::diagnostic_information(e)
27 
28 namespace WireCell {
29 
30  /// The base wire cell exception.
31  struct Exception : virtual public std::exception , virtual boost::exception {
32  char const *what() const throw() { return diagnostic_information_what(*this); }
33  };
34 
35 
36  /// Thrown when a wrong value has been encountered.
37  struct ValueError : virtual public Exception { } ;
38 
39  /// Thrown when a wrong index is used.
40  struct IndexError : virtual public Exception { } ;
41 
42  /// Thrown when a wrong key or has been encountered.
43  struct KeyError : virtual public Exception { } ;
44 
45  /// Thrown when an error involving accessing input or output has occurred.
46  class IOError : virtual public Exception { } ;
47 
48  /// Thrown when an error occurs during the data processing
49  class RuntimeError : virtual public Exception { } ;
50 
51  /// Thrown when an assertion fails
52  class AssertionError : virtual public Exception { } ;
53 
54  typedef boost::error_info<struct tag_errmsg, std::string> errmsg;
55 
56 }
57 #endif
Thrown when an error involving accessing input or output has occurred.
Definition: Exceptions.h:46
boost::error_info< struct tag_errmsg, std::string > errmsg
Definition: Exceptions.h:54
char const * what() const
Definition: Exceptions.h:32
Thrown when a wrong index is used.
Definition: Exceptions.h:40
Thrown when a wrong value has been encountered.
Definition: Exceptions.h:37
Definition: Main.h:22
The base wire cell exception.
Definition: Exceptions.h:31
Thrown when an error occurs during the data processing.
Definition: Exceptions.h:49
Thrown when an assertion fails.
Definition: Exceptions.h:52
Thrown when a wrong key or has been encountered.
Definition: Exceptions.h:43
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33