HepMC3 event record library
Errors.h
Go to the documentation of this file.
1// -*- C++ -*-
2//
3// This file is part of HepMC
4// Copyright (C) 2014-2019 The HepMC collaboration (see AUTHORS for details)
5/**
6 * @file Errors.h
7 * @brief Implementation of error and warning macros
8 *
9 */
10#ifndef HEPMC3_ERRORS_H
11#define HEPMC3_ERRORS_H
12
13#include <iostream>
14#include <stdexcept>
15
16namespace HepMC3 {
17
18
19/// @name Printing macros
20//@{
21
22/** @brief Macro for printing error messages */
23#define ERROR(MESSAGE) if ( Setup::print_errors() ) { std::cerr << "ERROR::" << MESSAGE << std::endl; }
24
25/** @brief Macro for printing warning messages */
26#define WARNING(MESSAGE) if ( Setup::print_warnings() ) { std::cout << "WARNING::" << MESSAGE << std::endl; }
27
28// Debug messages and code that will not go to the release version
29#ifndef HEPMC3_RELEASE_VERSION
30
31/** @brief Macro for printing debug messages with appropriate debug level */
32#define DEBUG(LEVEL,MESSAGE) if( Setup::debug_level()>=(LEVEL) ) { std::cout << "DEBUG(" << LEVEL <<")::" << MESSAGE << std::endl; }
33/** @brief Macro for storing code useful for debugging */
34#define DEBUG_CODE_BLOCK( x ) x
35
36#else
37
38#define DEBUG( x,y )
39#define DEBUG_CODE_BLOCK( x )
40
41#endif
42
43//@}
44
45
46/// @name Exceptions
47//@{
48
49/// @class Exception
50/// @brief Standard runtime error
51struct Exception : public std::runtime_error {
52 Exception(const std::string& msg) : std::runtime_error(msg) {} ///< Default constructor
53};
54
55/// @brief Exception related to weight lookups, setting, and index consistency
56struct WeightError : public Exception {
57 WeightError(const std::string& msg) : Exception(msg) {} ///< Default constructor
58};
59
60//@}
61
62
63} // namespace HepMC3
64
65#endif
HepMC3 main namespace.
Definition ReaderGZ.h:28
Standard runtime error.
Definition Errors.h:51
Exception(const std::string &msg)
Default constructor.
Definition Errors.h:52
Exception related to weight lookups, setting, and index consistency.
Definition Errors.h:56
WeightError(const std::string &msg)
Default constructor.
Definition Errors.h:57