HepMC event record
build/outputs/include/HepMC/Errors.h
1 // -*- C++ -*-
2 //
3 // This file is part of HepMC
4 // Copyright (C) 2014-2015 The HepMC collaboration (see AUTHORS for details)
5 
6 #ifndef HEPMC_ERRORS_H
7 #define HEPMC_ERRORS_H
8 
9 #include "HepMC/Common.h"
10 
11 namespace HepMC {
12 
13 
14  /// @name Printing macros
15  //@{
16 
17  /** @brief Macro for printing error messages */
18  #define ERROR(MESSAGE) if ( Setup::print_errors() ) { std::cerr << "ERROR::" << MESSAGE << std::endl; }
19 
20  /** @brief Macro for printing warning messages */
21  #define WARNING(MESSAGE) if ( Setup::print_warnings() ) { std::cout << "WARNING::" << MESSAGE << std::endl; }
22 
23  // Debug messages and code that will not go to the release version
24  #ifndef HEPMC_RELEASE_VERSION
25 
26  /** @brief Macro for printing debug messages with appropriate debug level */
27  #define DEBUG(LEVEL,MESSAGE) if( Setup::debug_level()>=(LEVEL) ) { std::cout << "DEBUG(" << LEVEL <<")::" << MESSAGE << std::endl; }
28  /** @brief Macro for storing code useful for debugging */
29  #define DEBUG_CODE_BLOCK( x ) x
30 
31  #else
32 
33  #define DEBUG( x,y )
34  #define DEBUG_CODE_BLOCK( x )
35 
36  #endif
37 
38  //@}
39 
40 
41  /// @name Exceptions
42  /// @todo Move to a dedicated header once we have more than one
43  //@{
44 
45  /// @class Exception
46  /// @brief Standard runtime error
47  /// @todo Should it be GenException? It's a HepMC thing, but not really a "gen" thing
48  struct Exception : public std::runtime_error {
49  Exception(const std::string& msg) : std::runtime_error(msg) {} ///< Default constructor
50  };
51 
52  /// @brief Exception related to weight lookups, setting, and index consistency
53  struct WeightError : public Exception {
54  WeightError(const std::string& msg) : Exception(msg) {} ///< Default constructor
55  };
56 
57  //@}
58 
59 
60 } // namespace HepMC
61 
62 #endif
Exception related to weight lookups, setting, and index consistency.
STL namespace.
WeightError(const std::string &msg)
Default constructor.
Exception(const std::string &msg)
Default constructor.
Definition of template class SmartPointer.