00001 /* Ergo, version 3.7, a program for linear scaling electronic structure 00002 * calculations. 00003 * Copyright (C) 2018 Elias Rudberg, Emanuel H. Rubensson, Pawel Salek, 00004 * and Anastasia Kruchinina. 00005 * 00006 * This program is free software: you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation, either version 3 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00018 * 00019 * Primary academic reference: 00020 * Ergo: An open-source program for linear-scaling electronic structure 00021 * calculations, 00022 * Elias Rudberg, Emanuel H. Rubensson, Pawel Salek, and Anastasia 00023 * Kruchinina, 00024 * SoftwareX 7, 107 (2018), 00025 * <http://dx.doi.org/10.1016/j.softx.2018.03.005> 00026 * 00027 * For further information about Ergo, see <http://www.ergoscf.org>. 00028 */ 00029 00038 /* The Failure class is used for exception handling. * 00039 * It inherits std::exception which means that an instance of this * 00040 * class can be caught by catching std::exception& * 00041 * The "&" must be there, otherwise the failure message * 00042 * will be "cut out". * 00043 * Retrieve the message with a call to the member function "what()" * 00044 * * 00045 * * 00046 * \\\|||/// \ (C) Emanuel Rubensson, August, 2005 * 00047 * \ ~ ~ / \ * 00048 * | @ @ | \ mail: emanuel@theochem.kth.se * 00049 * oOo---(_)---oOo---\----------------------------------------------* 00050 * */ 00051 00052 #ifndef FAILURE 00053 #define FAILURE 00054 #include <exception> 00055 namespace mat 00056 { 00057 class Failure : public std::exception { 00058 const char* message; 00059 public: 00060 Failure() 00061 :message("Failure: No failure information available") 00062 {} 00063 explicit Failure (const char* msg) 00064 :message(msg) 00065 {} 00066 virtual ~Failure() throw() {} 00067 virtual const char* what() const throw() 00068 {return message;} 00069 }; 00070 00071 class Acceptable : public Failure { 00072 public: 00073 Acceptable() 00074 :Failure("Acceptable: No acceptable failure information available") 00075 {} 00076 explicit Acceptable (const char* msg) 00077 :Failure(msg) 00078 {} 00079 }; 00080 00081 class AcceptableMaxIter : public Acceptable { 00082 int maxiter; 00083 public: 00084 AcceptableMaxIter() 00085 :Acceptable("AcceptableMaxIter: No acceptable failure information available"), 00086 maxiter(0) 00087 {} 00088 explicit AcceptableMaxIter (const char* msg, int maxi = 0) 00089 :Acceptable(msg), maxiter(maxi) 00090 {} 00091 int get_maxiter() const { 00092 return maxiter; 00093 } 00094 }; 00095 00096 } /* end namespace */ 00097 #endif