Greens-code
A modular quantum transport code
exceptions.hpp
1 #ifndef EXC_TRFILE_H
2 #define EXC_TRFILE_H
3 
4 #include <iostream>
5 #include <string>
6 #include <exception>
7 
9 
13 class super_Matrix_Invalid_request: public std::exception{
14  const char* msg;
15 public:
16  explicit super_Matrix_Invalid_request(const char* m): msg(m){};
17  const char* what() const throw (){return msg;};
18 };
19 
20 class E_invalid_pencil: public std::exception{
21 public:
22  std::string name;
23  std::string H_name;
24 
25  explicit E_invalid_pencil(const std::string& p,
26  const std::string& h): name(p), H_name(h){};
27  ~E_invalid_pencil() throw() {};
28 
29  const char* what() const throw(){
30  return "Hamiltonian does not accept his own pencil.\n";
31  };
32 };
33 
35 public:
36  const char* message;
37 
38  explicit E_dft_error(char* m):message(m){};
39  ~E_dft_error(){};
40 
41  const char* what() const throw() { return message;};
42 
43 };
44 
45 class E_invalid_param_value: public std::exception{
46 public:
47  const char* Object_name;
48  std::string Param_name;
49 
50  explicit E_invalid_param_value(const std::string& pn, const char* on):
51  Object_name(on), Param_name(pn){};
52  ~E_invalid_param_value() throw() {};
53  const char* what() const throw(){
54  return "Invalid Parameter value.\n";
55  };
56 };
57 
58 class E_invalid_dynamic_cast: public std::exception{
59 public:
60  const char* Object_name;
61  std::string Param_name;
62 
63  explicit E_invalid_dynamic_cast(const std::string& s, const char* on):
64  Object_name(on), Param_name(s){};
65  ~E_invalid_dynamic_cast() throw() {};
66  const char* what() const throw(){
67  return "Essential Parameter missing.\n";
68  };
69 };
70 
71 class E_missing_parameter: public std::exception{
72 public:
73  const char* Object_name;
74  std::string Param_name;
75 
76  explicit E_missing_parameter(const std::string& pn, const char* on):
77  Object_name(on), Param_name(pn){
78  std::cerr << "Missing parameter : " << pn << ' ' << on << '\n';
79  };
80  ~E_missing_parameter() throw() {};
81  const char* what() const throw(){
82  std::cerr << "Parameter "<< Param_name <<" missing on " << Object_name << "\n";
83  return "Essential Parameter missing.\n";
84  };
85 };
86 
87 class E_missing_XML_attribute: public std::exception{
88 public:
89  const std::string key;
90 
91  explicit E_missing_XML_attribute(const std::string& k):
92  key(k) {};
93  ~E_missing_XML_attribute() throw() {};
94  const char* what() const throw(){
95  return "XML attribute missing.\n";
96  };
97 };
98 
99 class E_double_XML_name: public std::exception{
100 public:
101  const std::string name;
102 
103  explicit E_double_XML_name(const std::string& k):
104  name(k) {};
105  ~E_double_XML_name() throw() {};
106  const char* what() const throw(){
107  return "Same XML object name used twice.\n";
108  };
109 };
110 
111 class E_XML_mixup: public std::exception{
112 public:
113  const std::string section;
114  explicit E_XML_mixup(const std::string& s):
115  section(s) {};
116  ~E_XML_mixup() throw() {};
117  const char* what() const throw(){
118  return "XML Section \"object\" unexpected.\n";
119  };
120 };
121 
122 class E_XML_unknown: public std::exception{
123 public:
124  const std::string section;
125  explicit E_XML_unknown(const std::string& s):
126  section(s) {};
127  ~E_XML_unknown() throw() {};
128  const char* what() const throw(){
129  return "XML object unknown.\n";
130  };
131 };
132 
133 class E_unknown_typename: public std::exception{
134 public:
135  std::string type_name;
136  explicit E_unknown_typename(const std::string& tn):type_name(tn){};
137  ~E_unknown_typename() throw() {};
138  const char* what() const throw(){
139  return "Typename identifier not known!\n";
140  };
141 };
142 
143 class E_circular_reference: public std::exception{
144 public:
145  std::string obj_class;
146  explicit E_circular_reference(const std::string& tn):obj_class(tn){};
147  ~E_circular_reference() throw() {};
148  const char* what() const throw(){
149  return "Circular reference in object dependencies!\n";
150  };
151 };
152 
153 class E_Bad_Size: public std::exception{
154 public:
155  int index;
156  explicit E_Bad_Size(const int i): index(i){};
157  const char* what() const throw (){return "Size missmatch in Matrix operation!";};
158 };
159 
160 class E_already_connected: public std::exception{
161 public:
162  int index;
163  explicit E_already_connected(const int i): index(i){};
164  const char* what() const throw (){return "Tried to connect twice, module already connected!";};
165 };
166 
167 class E_Is_Leaf: public std::exception{
168 public:
169  explicit E_Is_Leaf(){};
170  const char* what() const throw (){return "Rectangle does not contain Rectangle Parts!";};
171 };
172 
173 class E_Is_No_Leaf: public std::exception{
174 public:
175  explicit E_Is_No_Leaf(){};
176  const char* what() const throw (){return "Rectangle does not contain Hamiltonian!";};
177 };
178 
179 class E_Not_ready: public std::exception{
180 public:
181  const char* object;
182 
183  explicit E_Not_ready(const char* c):object(c){};
184  const char* what() const throw (){return "Object not initialized!";};
185 };
186 
187 class E_unknown_command: public std::exception{
188  std::string k;
189  public:
190  E_unknown_command(const std::string& s):k(s){};
191  ~E_unknown_command() throw() {};
192  char const *what() const throw() {return "The provided command is unknown.";};
193  const std::string& Command_name() const throw() {return k;};
194 };
195 
196 class E_syntax_error: public std::exception{
197  public:
198  E_syntax_error(){};
199  ~E_syntax_error() throw() {};
200  char const *what() const throw() {return "Syntax error!";};
201 };
202 
203 class E_incompatible_average: public std::exception{
204  std::string k;
205  public:
206  E_incompatible_average(const std::string& s):k(s){};
207  ~E_incompatible_average() throw() {};
208  char const *what() const throw() {return "The average over these two datasets is impossible.";};
209  const std::string& H_name() const throw() {return k;};
210 };
211 
212 class E_unknown_H: public std::exception{
213  std::string k;
214  public:
215  E_unknown_H(const std::string& s):k(s){};
216  ~E_unknown_H() throw() {};
217  char const *what() const throw() {return "The provided Hamiltonian is unknown.";};
218  const std::string& H_name() const throw() {return k;};
219 };
220 
221 class E_key_not_found: public std::exception{
222  std::string k;
223  public:
224  E_key_not_found(const std::string& s):k(s){};
225  ~E_key_not_found() throw() {};
226  char const *what() const throw() {return "The provided key was not found.";};
227  const std::string& key_name() const throw() {return k;};
228 };
229 
230 class E_invalid_filename: public std::exception{
231  std::string k;
232  public:
233  E_invalid_filename(const std::string& s):k(s){};
234  ~E_invalid_filename() throw() {};
235  char const *what() const throw() {return "The provided filename is invalid.";};
236  const std::string& filename() const throw() {return k;};
237 };
238 
239 class E_uninintialized_Rect: public std::exception{
240  int k;
241  public:
242  E_uninintialized_Rect(const int i):k(i){};
243  ~E_uninintialized_Rect() throw() {};
244  char const *what() const throw() {return "The Rectangle is uninizialised.";};
245  int Rect_Nr() const throw() {return k;};
246 };
247 
248 class E_invalid_TRfile: public std::exception{
249  public:
250  E_invalid_TRfile(){};
251  ~E_invalid_TRfile() throw() {};
252  char const *what() const throw() {return "The provided TRfile could not be loaded.";};
253 };
254 
255 class E_bad_index: public std::exception{
256  public:
257  int index;
258  E_bad_index():index(0){};
259  E_bad_index(const int i):index(i){};
260  ~E_bad_index() throw() {};
261  char const *what() const throw() {return "The provided index is out of range.";};
262 };
263 
264 class E_bad_range_string: public std::exception{
265  std::string k;
266  public:
267  E_bad_range_string(const std::string& s):k(s){};
268  ~E_bad_range_string() throw() {};
269  char const *what() const throw() {return "The provided range string "
270  "could not be parsed.";};
271  const std::string& parse_string() const throw() {return k;};
272 };
273 
274 class E_index_out_of_range: public std::exception{
275  size_t val;
276  size_t max;
277 public:
278  E_index_out_of_range(size_t v, size_t m):val(v), max(m){};
279  ~E_index_out_of_range() throw() {};
280  char const *what() const throw() {return "The provided index was out of range.";};
281  size_t get_val(){return val;};
282  size_t get_max(){return max;};
283 };
284 
285 class E_low_function_value: public std::exception{
286 public:
287  const char* Object_name;
288  std::string Param_name;
289 
290  explicit E_low_function_value(const std::string& pn, const char* on):
291  Object_name(on), Param_name(pn){};
292  ~E_low_function_value() throw() {};
293  const char* what() const throw(){
294  return "all values are to low for this calculation.\n";
295  };
296 };
297 
298 class E_wrong_parameter_number: public std::exception{
299 public:
300 
301  explicit E_wrong_parameter_number() {};
302  ~E_wrong_parameter_number() throw() {};
303  const char* what() const throw(){
304  return "The number of parameters in multi_slice_hamiltonian type is badly choosen. \n\
305 The number of nn parameters should never exceed 15 \n\
306 also certain nn parameter numbers lead to a highly degenerate interaction Hamiltonian and lead to errors for greensfunction calculations \n\
307 for eigenstate calculation set higher nn parameters to zero \n";
308  };
309 };
310 
311 #ifndef USE_ABSTRACT_FUNCTIONS
312 class E_real_virtual_function: public std::exception{
313 public:
314  const char* Object_name;
315  const std::string function_name;
316 
317  explicit E_real_virtual_function(const std::string& pn, const char* on):
318  Object_name(on), function_name(pn){};
319  ~E_real_virtual_function() throw() {};
320  const char* what() const throw(){
321  std::cerr << "The function:\n"<< function_name << "\nis not defined in \n" <<Object_name<<"\n explicitly declare it in derived class";
322  return "explicitly declare it in derived class";
323 
324  };
325 };
326 #endif
327 #endif
Definition: exceptions.hpp:255
Definition: exceptions.hpp:167
Definition: exceptions.hpp:179
Definition: exceptions.hpp:274
Definition: exceptions.hpp:221
Definition: exceptions.hpp:212
Definition: exceptions.hpp:45
Definition: exceptions.hpp:133
Definition: exceptions.hpp:196
Definition: messages.hpp:15
Definition: exceptions.hpp:20
Definition: exceptions.hpp:312
Definition: exceptions.hpp:111
Definition: exceptions.hpp:122
Definition: exceptions.hpp:264
Definition: exceptions.hpp:230
Definition: exceptions.hpp:160
Definition: exceptions.hpp:143
Definition: exceptions.hpp:203
An invalid request for matrix inversion.
Definition: exceptions.hpp:13
Definition: exceptions.hpp:87
Definition: exceptions.hpp:58
Definition: exceptions.hpp:71
Definition: exceptions.hpp:99
Definition: exceptions.hpp:173
Definition: exceptions.hpp:248
Definition: exceptions.hpp:298
Definition: exceptions.hpp:187
Definition: exceptions.hpp:153
Definition: exceptions.hpp:239
Definition: exceptions.hpp:285
Definition: exceptions.hpp:34