A Discrete-Event Network Simulator
QKDNetSim v2.0 (NS-3 v3.41) @ (+)
API
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
fatal-error.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2006 INRIA, 2010 NICTA
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation;
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  *
17  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
18  * Quincy Tse <quincy.tse@nicta.com.au>
19  */
20 #ifndef NS3_FATAL_ERROR_H
21 #define NS3_FATAL_ERROR_H
22 
23 #include "fatal-impl.h"
24 #include "log.h" // NS_LOG_APPEND...
25 
26 #include <cstdlib>
27 #include <exception>
28 #include <iostream>
29 #include <string_view>
30 
56 namespace ns3
57 {
58 
67 constexpr std::string_view NS_FATAL_MSG{"NS_FATAL, terminating"};
68 
69 } // namespace ns3
70 
88 #define NS_FATAL_ERROR_IMPL_NO_MSG(fatal) \
89  do \
90  { \
91  NS_LOG_APPEND_TIME_PREFIX_IMPL; \
92  NS_LOG_APPEND_NODE_PREFIX_IMPL; \
93  std::cerr << "file=" << __FILE__ << ", line=" << __LINE__ << std::endl; \
94  ::ns3::FatalImpl::FlushStreams(); \
95  if (fatal) \
96  { \
97  std::cerr << ns3::NS_FATAL_MSG << std::endl; \
98  std::terminate(); \
99  } \
100  } while (false)
101 
120 #define NS_FATAL_ERROR_IMPL(msg, fatal) \
121  do \
122  { \
123  std::cerr << "msg=\"" << msg << "\", "; \
124  NS_FATAL_ERROR_IMPL_NO_MSG(fatal); \
125  } while (false)
126 
142 #define NS_FATAL_ERROR_NO_MSG() NS_FATAL_ERROR_IMPL_NO_MSG(true)
143 
158 #define NS_FATAL_ERROR_NO_MSG_CONT() NS_FATAL_ERROR_IMPL_NO_MSG(false)
159 
179 #define NS_FATAL_ERROR(msg) NS_FATAL_ERROR_IMPL(msg, true)
180 
195 #define NS_FATAL_ERROR_CONT(msg) NS_FATAL_ERROR_IMPL(msg, false)
196 
197 #endif /* FATAL_ERROR_H */
ns3::FatalImpl::RegisterStream(), ns3::FatalImpl::UnregisterStream(), and ns3::FatalImpl::FlushStream...
constexpr std::string_view NS_FATAL_MSG
Output string marking imminent invocation of std::terminate.
Definition: fatal-error.h:67
Debug message logging.
Every class exported by the ns3 library is enclosed in the ns3 namespace.