|
degate 0.1.1
|
00001 /* -*-c++-*- 00002 00003 This file is part of the IC reverse engineering tool degate. 00004 00005 Copyright 2008, 2009, 2010 by Martin Schobert 00006 00007 Degate is free software: you can redistribute it and/or modify 00008 it under the terms of the GNU General Public License as published by 00009 the Free Software Foundation, either version 3 of the License, or 00010 any later version. 00011 00012 Degate is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 GNU General Public License for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with degate. If not, see <http://www.gnu.org/licenses/>. 00019 00020 */ 00021 00022 #ifndef __DEGATE_EXCEPTIONS_H__ 00023 #define __DEGATE_EXCEPTIONS_H__ 00024 00025 #include <stdexcept> 00026 00027 namespace degate { 00028 00029 /** 00030 * Generic runtime exception in libdegate. 00031 * @todo Check for std::runtime_error exceptions in the 00032 * code and replace it with a DegateRuntimeException. 00033 */ 00034 00035 class DegateRuntimeException : public std::runtime_error { 00036 public: 00037 DegateRuntimeException() : std::runtime_error("There is a generic runtime error in libdegate.") {} 00038 DegateRuntimeException(std::string str) : std::runtime_error(str) {} 00039 }; 00040 00041 00042 /** 00043 * Represents a runtime exception, that reflects an inconsistency in the logic model or gate library. 00044 */ 00045 00046 class DegateInconsistencyException : public DegateRuntimeException { 00047 public: 00048 DegateInconsistencyException() : DegateRuntimeException("There is a generic inconsistence in either the logic model or gate library.") {} 00049 DegateInconsistencyException(std::string str) : DegateRuntimeException(str) {} 00050 }; 00051 00052 00053 00054 /** 00055 * Represents a this-should-not-happen problem and indicates a 00056 * programming error. This class is is derived from std::logic_error. 00057 * This excpetion should not go unnoticed. You should not 00058 * catch it. It is ok, that the application will abort, because 00059 * this exception already indicates that it is already broken. 00060 * 00061 * @todo Check for std::logic_error exceptions in the 00062 * code and replace it with a GenericDegateException. 00063 */ 00064 00065 class DegateLogicException : public std::logic_error { 00066 public: 00067 DegateLogicException() : 00068 std::logic_error("There is a generic logic error in libdegate. " 00069 "This indicates a programming error.") {} 00070 DegateLogicException(std::string str) : std::logic_error(str) {} 00071 }; 00072 00073 00074 /** 00075 * This exception is raised if a code fragment receives a null pointer 00076 * where this should not happen. 00077 */ 00078 00079 class InvalidPointerException : public DegateLogicException { 00080 public: 00081 InvalidPointerException() : DegateLogicException("Invalid pointer value.") {} 00082 InvalidPointerException(std::string str) : DegateLogicException(str) {} 00083 }; 00084 00085 00086 /** 00087 * This exception is raised if a method detects an invalid Object ID. 00088 * Object IDs are managed by the logic model. Probably the object was 00089 * not inserted into the logic model. 00090 */ 00091 00092 class InvalidObjectIDException : public DegateLogicException { 00093 public: 00094 InvalidObjectIDException() : 00095 DegateLogicException("The logic model object has no or an invalid object ID.") {} 00096 InvalidObjectIDException(std::string str) : DegateLogicException(str) {} 00097 }; 00098 00099 00100 /** 00101 * Indicates a runtime exception from the XML parser. 00102 */ 00103 00104 class InvalidXMLException : public DegateRuntimeException { 00105 public: 00106 InvalidXMLException() : DegateRuntimeException("XML is invalid." ) {} 00107 InvalidXMLException(std::string const & str) : DegateRuntimeException(str) {} 00108 }; 00109 00110 /** 00111 * This exception is thrown if a XML importer failed to parse a 00112 * value of an XML attribute. 00113 */ 00114 00115 class XMLAttributeParseException : public DegateRuntimeException { 00116 public: 00117 XMLAttributeParseException() : DegateRuntimeException("Can't parse XML attribute value." ) {} 00118 XMLAttributeParseException(std::string const & str) : DegateRuntimeException(str) {} 00119 }; 00120 00121 /** 00122 * This exception is thrown if a XML importer detects a missing XML attribute 00123 * and this XML attribute must be present. 00124 */ 00125 00126 class XMLAttributeMissingException : public DegateRuntimeException { 00127 public: 00128 XMLAttributeMissingException() : DegateRuntimeException("XML attribute is missing." ) {} 00129 XMLAttributeMissingException(std::string const & str) : DegateRuntimeException(str) {} 00130 }; 00131 00132 /** 00133 * This exception is thrown if a method failed to lookup an object 00134 * in a collection type, such as in a std::map or list. 00135 */ 00136 00137 class CollectionLookupException : public DegateRuntimeException { 00138 public: 00139 CollectionLookupException() : DegateRuntimeException("Failed to lookup an object in a collection." ) {} 00140 CollectionLookupException(std::string const & str) : DegateRuntimeException(str) {} 00141 }; 00142 00143 /** 00144 * This exception indicates, that a system operation failed. 00145 */ 00146 00147 class SystemException : public DegateRuntimeException { 00148 public: 00149 SystemException() : DegateRuntimeException("The file doesn't exist." ) {} 00150 SystemException(std::string const & str) : DegateRuntimeException(str) {} 00151 }; 00152 00153 /** 00154 * This exception indicates, that a file system operation failed. 00155 */ 00156 00157 class FileSystemException : public DegateRuntimeException { 00158 public: 00159 FileSystemException() : DegateRuntimeException("The file doesn't exist." ) {} 00160 FileSystemException(std::string const & str) : DegateRuntimeException(str) {} 00161 }; 00162 00163 00164 /** 00165 * This exception indicates an invalid path in the file system. 00166 */ 00167 class InvalidPathException : public FileSystemException { 00168 public: 00169 InvalidPathException() : FileSystemException("The file doesn't exist." ) {} 00170 InvalidPathException(std::string const & str) : FileSystemException(str) {} 00171 }; 00172 00173 /** 00174 * This exception indicates, that libdegate is unable to handle the image file format. 00175 */ 00176 class InvalidFileFormatException : public DegateRuntimeException { 00177 public: 00178 InvalidFileFormatException() : 00179 DegateRuntimeException("Can't read the file. It is an unknown image format.") {} 00180 InvalidFileFormatException(std::string const & str) : DegateRuntimeException(str) {} 00181 }; 00182 00183 00184 /** 00185 * This exception is thrown if a ZIP archive cannot be exported. 00186 */ 00187 00188 class ZipException : public DegateRuntimeException { 00189 public: 00190 ZipException() : DegateRuntimeException("Can't export ZIP archive." ) {} 00191 ZipException(std::string const & str) : DegateRuntimeException(str) {} 00192 }; 00193 00194 /** 00195 * Indicates a runtime exception from the XML parser. 00196 */ 00197 00198 class XMLRPCException : public DegateRuntimeException { 00199 public: 00200 XMLRPCException() : DegateRuntimeException("XMLRPC failed." ) {} 00201 XMLRPCException(std::string const & str) : DegateRuntimeException(str) {} 00202 }; 00203 00204 00205 } 00206 00207 #endif
1.7.4