hemocell
Loading...
Searching...
No Matches
error.h
Go to the documentation of this file.
1/*
2This file is part of the HemoCell library
3
4HemoCell is developed and maintained by the Computational Science Lab
5in the University of Amsterdam. Any questions or remarks regarding this library
6can be sent to: info@hemocell.eu
7
8When using the HemoCell library in scientific work please cite the
9corresponding paper: https://doi.org/10.3389/fphys.2017.00563
10
11The HemoCell library is free software: you can redistribute it and/or
12modify it under the terms of the GNU Affero General Public License as
13published by the Free Software Foundation, either version 3 of the
14License, or (at your option) any later version.
15
16The library is distributed in the hope that it will be useful,
17but WITHOUT ANY WARRANTY; without even the implied warranty of
18MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19GNU Affero General Public License for more details.
20
21You should have received a copy of the GNU Affero General Public License
22along with this program. If not, see <http://www.gnu.org/licenses/>.
23*/
24#ifndef HEMOCELL_ERROR_H
25#define HEMOCELL_ERROR_H
26
27#include <sstream>
28#include <stdexcept>
29#include <string>
30
31namespace hemo {
32
35class FatalError : public std::runtime_error {
36public:
37 explicit FatalError(const std::string & message) : std::runtime_error(message) {}
38};
39
55[[noreturn]] void fatal(const std::string & message);
56
59void warning(const std::string & message);
60
61namespace detail {
62inline void streamAll(std::ostringstream &) {}
63template <typename First, typename... Rest>
64void streamAll(std::ostringstream & out, const First & first, const Rest &... rest) {
65 out << first;
66 streamAll(out, rest...);
67}
68} // namespace detail
69
72template <typename First, typename Second, typename... Rest>
73[[noreturn]] void fatal(const First & first, const Second & second, const Rest &... rest) {
74 std::ostringstream message;
75 detail::streamAll(message, first, second, rest...);
76 fatal(message.str());
77}
78
80template <typename First, typename Second, typename... Rest>
81void warning(const First & first, const Second & second, const Rest &... rest) {
82 std::ostringstream message;
83 detail::streamAll(message, first, second, rest...);
84 warning(message.str());
85}
86
96
97} // namespace hemo
98#endif
Definition error.h:35
FatalError(const std::string &message)
Definition error.h:37
Definition error.h:89
FatalErrorsThrow(const FatalErrorsThrow &)=delete
~FatalErrorsThrow()
Definition error.cpp:75
FatalErrorsThrow()
Definition error.cpp:71
FatalErrorsThrow & operator=(const FatalErrorsThrow &)=delete
void streamAll(std::ostringstream &)
Definition error.h:62
Definition config.cpp:37
void fatal(const std::string &message)
Report a fatal error and end the whole MPI job.
Definition error.cpp:59
void warning(const std::string &message)
Definition error.cpp:67