ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
RuntimeError.cpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2014-2022 The ESPResSo project
3 *
4 * This file is part of ESPResSo.
5 *
6 * ESPResSo is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * ESPResSo is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
21
22#include <iostream>
23#include <sstream>
24#include <string>
25
26namespace ErrorHandling {
27
28std::string RuntimeError::format() const {
29 std::string label;
30
31 switch (m_level) {
33 label = "DEBUG";
34 break;
36 label = "WARNING";
37 break;
39 label = "ERROR";
40 break;
42 label = "INFO";
43 break;
44 }
45
46 std::ostringstream ostr;
47
48 ostr << label << ": " << what();
49
50#ifndef NDEBUG
51 ostr << " in function " << function() << " (" << file() << ":" << line()
52 << ") on node " << who();
53#endif
54
55 return ostr.str();
56}
57void RuntimeError::print() const { std::cerr << format() << std::endl; }
58
59} // namespace ErrorHandling
int line() const
The line where the error occurred.
std::string what() const
The Error Message.
std::string format() const
Get a string representation.
std::string function() const
The function where the error occurred.
int who() const
Which MPI node raised the error.
std::string file() const
The file where the error occurred.