My Project
Loading...
Searching...
No Matches
ErrorGuard.hpp
1/*
2 Copyright 2019 Joakim Hove/datagr
3
4 This file is part of the Open Porous Media project (OPM).
5
6 OPM 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 OPM 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 OPM. If not, see <http://www.gnu.org/licenses/>.
18*/
19
20
21#ifndef ERROR_GUARD_HPP
22#define ERROR_GUARD_HPP
23
24#include <cstddef>
25#include <string>
26#include <vector>
27
28namespace Opm {
29
31public:
32 void addError(const std::string& errorKey, const std::string& msg);
33 void addWarning(const std::string& errorKey, const std::string &msg);
34 void clear();
35
36 explicit operator bool() const { return !this->error_list.empty(); }
37
38 /*
39 Observe that this destructor has somewhat special semantics. If there
40 are errors in the error list it will print all warnings and errors on
41 stderr with the dump() method, and then call std::exit(1).
42 */
44 void terminate() const;
45 void dump() const;
46 std::string formattedErrors() const;
47
48private:
49 std::size_t maxMessageWidth() const;
50
51 std::vector<std::pair<std::string, std::string>> error_list;
52 std::vector<std::pair<std::string, std::string>> warning_list;
53};
54
55}
56
57#endif
Definition ErrorGuard.hpp:30
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30