DeSR Dependency Parser |
00001 /* 00002 ** IXE C++ Library 00003 ** ixe/include/error.h 00004 ** ---------------------------------------------------------------------- 00005 ** Copyright (c) 2000 Ideare SpA. 00006 ** Copyright (c) 2000 Giuseppe Attardi (attardi@di.unipi.it). 00007 ** ---------------------------------------------------------------------- 00008 ** 00009 ** This file is part of DeSR. 00010 ** 00011 ** DeSR is free software; you can redistribute it and/or modify it 00012 ** under the terms of the GNU General Public License, version 3, 00013 ** as published by the Free Software Foundation. 00014 ** 00015 ** DeSR is distributed in the hope that it will be useful, 00016 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 ** GNU General Public License for more details. 00019 ** 00020 ** You should have received a copy of the GNU General Public License 00021 ** along with this program. If not, see <http://www.gnu.org/licenses/>. 00022 ** ---------------------------------------------------------------------- 00023 */ 00024 00025 #ifndef IXE_ERROR_H 00026 #define IXE_ERROR_H 00027 00028 // Settings 00029 #include "platform.h" 00030 00031 // standard 00032 #include <stdexcept> 00033 00034 // local 00035 00036 namespace IXE { 00037 00039 class Error : public std::exception 00040 { 00041 private: 00042 std::string msg; 00043 00045 void operator=(const Error ©me); 00046 protected: 00050 Error(std::string const& error_msg) : msg(error_msg) {} 00051 Error(const Error ©me) : msg(copyme.msg) {} 00052 public: 00056 std::string message() { return msg; } 00057 00058 virtual ~Error() throw() { } 00059 }; 00060 00061 //---------------------------------------------------------------------- 00062 00067 class LogicError : public Error { 00068 protected: 00069 LogicError(std::string const& msg) : Error(msg) {} 00070 }; 00071 00077 class RuntimeError : public Error { 00078 protected: 00079 RuntimeError(std::string const& msg) : Error(msg) {} 00080 }; 00081 00082 //---------------------------------------------------------------------- 00083 00086 class AssertionError : public LogicError { 00087 public: 00088 AssertionError(std::string const& msg) : 00089 LogicError(msg + " - assertion failed") {} 00090 }; 00091 00093 class UnimplementedError : public LogicError { 00094 public: 00095 UnimplementedError(std::string const& msg) : LogicError(msg) {} 00096 }; 00097 00099 class InvalidArgumentError : public LogicError { 00100 public: 00101 InvalidArgumentError(std::string const& msg) : LogicError(msg) {} 00102 }; 00103 00104 //---------------------------------------------------------------------- 00105 00107 class ConfigFileError : public RuntimeError { 00108 public: 00109 ConfigFileError(std::string const& msg) : RuntimeError(msg) {} 00110 }; 00111 00113 class FileError : public RuntimeError { 00114 public: 00115 FileError(std::string const& msg) : RuntimeError(msg) {} 00116 }; 00117 00119 class MmapError : public RuntimeError { 00120 public: 00121 MmapError(std::string const& msg) : RuntimeError(msg) {} 00122 }; 00123 00125 class FormatError : public RuntimeError { 00126 public: 00127 FormatError(std::string const& msg) : RuntimeError(msg) {} 00128 }; 00129 00133 class DocNotFoundError : public RuntimeError { 00134 public: 00135 DocNotFoundError(std::string const& msg) : RuntimeError(msg) {} 00136 }; 00137 00139 class InternalError : public RuntimeError { 00140 public: 00141 InternalError(std::string const& msg) : RuntimeError(msg) {} 00142 }; 00143 00145 class IndexingError : public RuntimeError { 00146 public: 00147 IndexingError(std::string const& msg) : RuntimeError(msg) {} 00148 }; 00149 00151 class RangeError : public RuntimeError { 00152 public: 00153 RangeError(std::string const& msg) : RuntimeError(msg) {} 00154 }; 00155 00157 class ReaderError : public RuntimeError { 00158 public: 00159 ReaderError(std::string const& msg) : RuntimeError(msg) {} 00160 }; 00161 00163 class CollectionError : public RuntimeError { 00164 public: 00165 CollectionError(std::string const& msg) : RuntimeError(msg) {} 00166 }; 00167 00171 class NetworkError : public RuntimeError { 00172 public: 00173 NetworkError(std::string const& msg) : RuntimeError(msg) {} 00174 }; 00175 00179 class MemoryError : public RuntimeError { 00180 public: 00181 MemoryError(std::string const& msg) : RuntimeError(msg) {} 00182 }; 00183 00185 class OpeningError : public CollectionError { 00186 public: 00187 OpeningError(std::string const& msg) : CollectionError(msg) {} 00188 }; 00189 00191 class TableError : public CollectionError { 00192 public: 00193 TableError(std::string const& msg) : CollectionError(msg) {} 00194 }; 00195 00196 class ParserError : public RuntimeError { 00197 public: 00198 ParserError(char const* msg) : RuntimeError(msg) {} 00199 }; 00200 00202 class QueryError : public RuntimeError { 00203 public: 00204 QueryError(std::string const& msg) : RuntimeError(msg) {} 00205 }; 00206 00208 class InvalidResultError : public RuntimeError { 00209 public: 00210 InvalidResultError(std::string const& msg) : RuntimeError(msg) {} 00211 }; 00212 00214 class SystemError : public RuntimeError { 00215 public: 00216 SystemError(std::string const& msg) : RuntimeError(msg) {} 00217 }; 00218 00219 class IOError : public RuntimeError { 00220 public: 00221 IOError(std::string const& msg) : RuntimeError(msg) {} 00222 IOError(char const* msg) : RuntimeError(msg) {} 00223 }; 00224 00226 // System errors 00227 00228 #define SYS_CALL(method, args) \ 00229 if (!(method args)) \ 00230 throw SystemError(std::string("*** SystemError at " __FILE__ ":") \ 00231 + __LINE__ + ". Failed: " #method #args) 00232 00233 } // namespace IXE 00234 00235 #endif /* IXE_ERROR_H */