1 /* 2 * CCvcExceptions.hh 3 * 4 * Copyright 2014-2018 D. Mitch Bailey cvc at shuharisystem dot com 5 * 6 * This file is part of cvc. 7 * 8 * cvc is free software: you can redistribute it and/or modify 9 * it under the terms of the GNU General Public License as published by 10 * the Free Software Foundation, either version 3 of the License, or 11 * (at your option) any later version. 12 * 13 * cvc is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with cvc. If not, see <http://www.gnu.org/licenses/>. 20 * 21 * You can download cvc from https://github.com/d-m-bailey/cvc.git 22 */ 23 24 #ifndef CCVCEXCEPTIONS_HH_ 25 #define CCVCEXCEPTIONS_HH_ 26 27 #include "Cvc.hh" 28 29 class EEquivalenceError : public exception { 30 public: what() const31 const char* what() const noexcept { return "Could not short nets connected to different power"; } 32 }; 33 34 class EPowerDefinition : public exception { 35 public: what() const36 const char* what() const noexcept { return "Power definition problem"; } 37 }; 38 39 40 class EUnknownModel : public exception { 41 public: what() const42 const char* what() const noexcept { return "Unknown model"; } 43 }; 44 45 class EInvalidTerminal : public exception { 46 public: 47 string errorMessage = ""; EInvalidTerminal(const string theErrorMessage)48 EInvalidTerminal(const string theErrorMessage) { errorMessage = theErrorMessage; }; what() const49 const char* what() const noexcept { string myMessage = "Invalid terminal: " + errorMessage; return myMessage.c_str(); } 50 }; 51 52 class EModelError : public exception { 53 public: 54 string errorMessage = ""; 55 EModelError(); EModelError(const string theErrorMessage)56 EModelError(const string theErrorMessage) { errorMessage = theErrorMessage; }; what() const57 const char* what() const noexcept { string myMessage = "Model error: " + errorMessage; return myMessage.c_str(); } 58 }; 59 60 class EDuplicateInstance : public exception { 61 public: what() const62 const char* what() const noexcept { return "Duplicate instance"; } 63 }; 64 65 class EDatabaseError : public exception { 66 public: 67 string errorMessage = ""; 68 EDatabaseError(); EDatabaseError(const string theErrorMessage)69 EDatabaseError(const string theErrorMessage) { errorMessage = theErrorMessage; }; what() const70 const char* what() const noexcept { string myMessage = "Database error:" + errorMessage; return myMessage.c_str(); } 71 }; 72 73 class EFatalError : public exception { 74 public: 75 string errorMessage = ""; 76 EFatalError(); EFatalError(const string theErrorMessage)77 EFatalError(const string theErrorMessage) { errorMessage = theErrorMessage; }; what() const78 const char* what() const noexcept { string myMessage = "Fatal error:" + errorMessage; return myMessage.c_str(); } 79 }; 80 81 class EBadEnvironment : public exception { 82 public: what() const83 const char* what() const noexcept { return "Bad environment"; } 84 }; 85 86 class EQueueError : public exception { 87 public: 88 string errorMessage = ""; 89 EQueueError(); EQueueError(const string theErrorMessage)90 EQueueError(const string theErrorMessage) { errorMessage = theErrorMessage; }; what() const91 const char* what() const noexcept { string myMessage = "Queue error:" + errorMessage; return myMessage.c_str(); } 92 }; 93 94 class EPowerError : public exception { 95 public: 96 string errorMessage = ""; 97 EPowerError(); EPowerError(const string theErrorMessage)98 EPowerError(const string theErrorMessage) { errorMessage = theErrorMessage; }; what() const99 const char* what() const noexcept { string myMessage = "Power error:" + errorMessage; return myMessage.c_str(); } 100 }; 101 102 class EResistanceError : public exception { 103 public: 104 string errorMessage = ""; 105 EResistanceError(); EResistanceError(const string theErrorMessage)106 EResistanceError(const string theErrorMessage) { errorMessage = theErrorMessage; }; what() const107 const char* what() const noexcept { string myMessage = "Resistance error:" + errorMessage; return myMessage.c_str(); } 108 }; 109 110 class EShortFileError : public exception { 111 public: 112 string errorMessage = ""; what() const113 const char* what() const noexcept { return "Error reading short file"; } 114 }; 115 116 #endif /* CCVCEXCEPTIONS_HH_ */ 117