Tanl Linguistic Pipeline |
00001 /* 00002 ** IXE 00003 ** include/error.h 00004 ** ---------------------------------------------------------------------- 00005 ** Copyright (c) 2000 Ideare SpA. All rights reserved. 00006 ** Copyright (c) 2000 Giuseppe Attardi (attardi@di.unipi.it) 00007 ** ---------------------------------------------------------------------- 00008 ** 00009 ** This file is part of IXE. 00010 ** 00011 ** IXE 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 ** IXE 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 #include "text/strings.h" 00036 00037 using namespace IXE::Text; 00038 00039 namespace IXE { 00040 00042 class Error : public std::exception 00043 { 00044 private: 00045 std::string msg; 00046 00048 void operator=(const Error ©me); 00049 protected: 00053 Error(std::string const& error_msg) : msg(error_msg) {} 00054 Error(const Error ©me) : msg(copyme.msg) {} 00055 public: 00059 std::string message() { return msg; } 00060 00061 virtual ~Error() throw() { } 00062 }; 00063 00064 //---------------------------------------------------------------------- 00065 00070 class LogicError : public Error { 00071 protected: 00072 LogicError(std::string const& msg) : Error(msg) {} 00073 }; 00074 00080 class RuntimeError : public Error { 00081 protected: 00082 RuntimeError(std::string const& msg) : Error(msg) {} 00083 }; 00084 00085 //---------------------------------------------------------------------- 00086 00089 class AssertionError : public LogicError { 00090 public: 00091 AssertionError(std::string const& msg) : 00092 LogicError(msg + " - assertion failed") {} 00093 }; 00094 00096 class UnimplementedError : public LogicError { 00097 public: 00098 UnimplementedError(std::string const& msg) : LogicError(msg) {} 00099 }; 00100 00102 class InvalidArgumentError : public LogicError { 00103 public: 00104 InvalidArgumentError(std::string const& msg) : LogicError(msg) {} 00105 }; 00106 00107 //---------------------------------------------------------------------- 00108 00110 class ConfigFileError : public RuntimeError { 00111 public: 00112 ConfigFileError(std::string const& msg) : RuntimeError(msg) {} 00113 }; 00114 00116 class FileError : public RuntimeError { 00117 public: 00118 FileError(std::string const& msg) : RuntimeError(msg) {} 00119 }; 00120 00122 class MmapError : public RuntimeError { 00123 public: 00124 MmapError(std::string const& msg) : RuntimeError(msg) {} 00125 }; 00126 00128 class FormatError : public RuntimeError { 00129 public: 00130 FormatError(std::string const& msg) : RuntimeError(msg) {} 00131 }; 00132 00136 class DocNotFoundError : public RuntimeError { 00137 public: 00138 DocNotFoundError(std::string const& msg) : RuntimeError(msg) {} 00139 }; 00140 00142 class InternalError : public RuntimeError { 00143 public: 00144 InternalError(std::string const& msg) : RuntimeError(msg) {} 00145 }; 00146 00148 class IndexingError : public RuntimeError { 00149 public: 00150 IndexingError(std::string const& msg) : RuntimeError(msg) {} 00151 }; 00152 00154 class RangeError : public RuntimeError { 00155 public: 00156 RangeError(std::string const& msg) : RuntimeError(msg) {} 00157 }; 00158 00160 class ReaderError : public RuntimeError { 00161 public: 00162 ReaderError(std::string const& msg) : RuntimeError(msg) {} 00163 }; 00164 00166 class CollectionError : public RuntimeError { 00167 public: 00168 CollectionError(std::string const& msg) : RuntimeError(msg) {} 00169 }; 00170 00174 class NetworkError : public RuntimeError { 00175 public: 00176 NetworkError(std::string const& msg) : RuntimeError(msg) {} 00177 }; 00178 00182 class MemoryError : public RuntimeError { 00183 public: 00184 MemoryError(std::string const& msg) : RuntimeError(msg) {} 00185 }; 00186 00188 class OpeningError : public CollectionError { 00189 public: 00190 OpeningError(std::string const& msg) : CollectionError(msg) {} 00191 }; 00192 00194 class TableError : public CollectionError { 00195 public: 00196 TableError(std::string const& msg) : CollectionError(msg) {} 00197 }; 00198 00199 class ParserError : public RuntimeError { 00200 public: 00201 ParserError(char const* msg) : RuntimeError(msg) {} 00202 }; 00203 00205 class QueryError : public RuntimeError { 00206 public: 00207 QueryError(std::string const& msg) : RuntimeError(msg) {} 00208 }; 00209 00211 class InvalidResultError : public RuntimeError { 00212 public: 00213 InvalidResultError(std::string const& msg) : RuntimeError(msg) {} 00214 }; 00215 00217 class SystemError : public RuntimeError { 00218 public: 00219 SystemError(std::string const& msg) : RuntimeError(msg) {} 00220 }; 00221 00222 class IOError : public RuntimeError { 00223 public: 00224 IOError(std::string const& msg) : RuntimeError(msg) {} 00225 IOError(char const* msg) : RuntimeError(msg) {} 00226 }; 00227 00229 // System errors 00230 00231 #define SYS_CALL(method, args) \ 00232 if (!(method args)) \ 00233 throw SystemError(std::string("*** SystemError at " __FILE__ ":") \ 00234 + __LINE__ + ". Failed: " #method #args) 00235 00236 } // namespace IXE 00237 00238 #endif /* IXE_ERROR_H */