ergo
Failure.h
Go to the documentation of this file.
1/* Ergo, version 3.8, a program for linear scaling electronic structure
2 * calculations.
3 * Copyright (C) 2019 Elias Rudberg, Emanuel H. Rubensson, Pawel Salek,
4 * and Anastasia Kruchinina.
5 *
6 * This program 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 * This program 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 * Primary academic reference:
20 * Ergo: An open-source program for linear-scaling electronic structure
21 * calculations,
22 * Elias Rudberg, Emanuel H. Rubensson, Pawel Salek, and Anastasia
23 * Kruchinina,
24 * SoftwareX 7, 107 (2018),
25 * <http://dx.doi.org/10.1016/j.softx.2018.03.005>
26 *
27 * For further information about Ergo, see <http://www.ergoscf.org>.
28 */
29
38/* The Failure class is used for exception handling. *
39 * It inherits std::exception which means that an instance of this *
40 * class can be caught by catching std::exception& *
41 * The "&" must be there, otherwise the failure message *
42 * will be "cut out". *
43 * Retrieve the message with a call to the member function "what()" *
44 * *
45 * *
46 * \\\|||/// \ (C) Emanuel Rubensson, August, 2005 *
47 * \ ~ ~ / \ *
48 * | @ @ | \ mail: emanuel@theochem.kth.se *
49 * oOo---(_)---oOo---\----------------------------------------------*
50 * */
51
52#ifndef FAILURE
53#define FAILURE
54#include <exception>
55namespace mat
56{
57 class Failure : public std::exception {
58 const char* message;
59 public:
61 :message("Failure: No failure information available")
62 {}
63 explicit Failure (const char* msg)
64 :message(msg)
65 {}
66 virtual ~Failure() throw() {}
67 virtual const char* what() const throw()
68 {return message;}
69 };
70
71 class Acceptable : public Failure {
72 public:
74 :Failure("Acceptable: No acceptable failure information available")
75 {}
76 explicit Acceptable (const char* msg)
77 :Failure(msg)
78 {}
79 };
80
83 public:
85 :Acceptable("AcceptableMaxIter: No acceptable failure information available"),
86 maxiter(0)
87 {}
88 explicit AcceptableMaxIter (const char* msg, int maxi = 0)
89 :Acceptable(msg), maxiter(maxi)
90 {}
91 int get_maxiter() const {
92 return maxiter;
93 }
94 };
95
96} /* end namespace */
97#endif
Definition: Failure.h:81
AcceptableMaxIter()
Definition: Failure.h:84
int maxiter
Definition: Failure.h:82
AcceptableMaxIter(const char *msg, int maxi=0)
Definition: Failure.h:88
int get_maxiter() const
Definition: Failure.h:91
Definition: Failure.h:71
Acceptable(const char *msg)
Definition: Failure.h:76
Acceptable()
Definition: Failure.h:73
Definition: Failure.h:57
Failure()
Definition: Failure.h:60
const char * message
Definition: Failure.h:58
virtual const char * what() const
Definition: Failure.h:67
virtual ~Failure()
Definition: Failure.h:66
Failure(const char *msg)
Definition: Failure.h:63
Definition: allocate.cc:39