BubbleProfiler  0.3.0
by Peter Athron, Csaba Balazs, Michael Bardsley, Andrew Fowlie, Dylan Harries & Graham White
error.hpp
Go to the documentation of this file.
1 /*
2  * This file is part of BubbleProfiler.
3  *
4  * BubbleProfiler is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * BubbleProfiler is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with BubbleProfiler. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef BUBBLEPROFILER_ERROR_HPP_INCLUDED
19 #define BUBBLEPROFILER_ERROR_HPP_INCLUDED
20 
21 #include <stdexcept>
22 #include <string>
23 
24 namespace BubbleProfiler {
25 
26 class Error : public std::runtime_error {
27 public:
28  using std::runtime_error::runtime_error;
29 };
30 
32 class Setup_error : public Error {
33 public:
34  using Error::Error;
35 };
36 
38 class Thin_wall_error : public Error {
39 public:
40  using Error::Error;
41 };
42 
44 class BVP_solver_error : public Error {
45 public:
46  using Error::Error;
47 
49  : Error("BVP_solver_error: failed to solve BVP")
50  {}
51 };
52 
54 class No_convergence_error : public Error {
55 public:
56  explicit No_convergence_error(int it_)
57  : Error("No_convergence_error: no convergence after "
58  + std::to_string(it_) + " iterations")
59  , iterations(it_)
60  {}
61  No_convergence_error(int it_, const std::string& what_)
62  : Error(what_), iterations(it_)
63  {}
64  No_convergence_error(int it_, const char* what_)
65  : Error(what_), iterations(it_)
66  {}
67 
68  int get_number_of_iterations() const { return iterations; }
69 
70 private:
71  int iterations{0};
72 };
73 
75 class Out_of_bounds_error : public Error {
76 public:
77  explicit Out_of_bounds_error(int idx_)
78  : Error("Out_of_bounds_error: attempted to access out of bounds index "
79  + std::to_string(idx_))
80  , index(idx_)
81  {}
82  Out_of_bounds_error(int idx_, const std::string& what_)
83  : Error(what_)
84  , index(idx_)
85  {}
86  Out_of_bounds_error(int idx_, const char* what_)
87  : Error(what_)
88  , index(idx_)
89  {}
90 
91  int get_index_value() const { return index; }
92 
93 private:
94  int index{0};
95 };
96 
98 class Out_of_memory_error : public Error {
99 public:
100  using Error::Error;
101 };
102 
104 class Optimizer_error : public Error {
105 public:
106  using Error::Error;
107 };
108 
110 class Domain_error : public Error {
111 public:
112  using Error::Error;
113 };
114 
116 class Numerical_error : public Error {
117 public:
118  using Error::Error;
119 };
120 
122 class IO_error : public Error {
123 public:
124  using Error::Error;
125 };
126 
131 class Not_implemented_error : public Error {
132 public:
133  using Error::Error;
134 };
135 
136 } // namespace BubbleProfiler
137 
138 #endif
Exception indicating that the optimizer failed to converge.
Definition: error.hpp:104
Exception indicating failure to integrate BVP.
Definition: error.hpp:44
Exception indicating a thin-wall ansatz which we can&#39;t solve (yet!)
Definition: error.hpp:38
Exception indicating failure of iterative procedure to converge.
Definition: error.hpp:54
Exception indicating function evaluation out of allowed domain.
Definition: error.hpp:110
No_convergence_error(int it_, const char *what_)
Definition: error.hpp:64
Exception indicating that memory allocation failed.
Definition: error.hpp:98
Exception indicating generic input/output error.
Definition: error.hpp:122
No_convergence_error(int it_, const std::string &what_)
Definition: error.hpp:61
Exception indicating out of bounds access error.
Definition: error.hpp:75
Out_of_bounds_error(int idx_, const char *what_)
Definition: error.hpp:86
Exception indicating general setup error.
Definition: error.hpp:32
Out_of_bounds_error(int idx_, const std::string &what_)
Definition: error.hpp:82
Exception indicating generic numerical error.
Definition: error.hpp:116