dlvhex
2.5.0
|
00001 /* dlvhex -- Answer-Set Programming with external interfaces. 00002 * Copyright (C) 2005-2007 Roman Schindlauer 00003 * Copyright (C) 2006-2015 Thomas Krennwallner 00004 * Copyright (C) 2009-2016 Peter Schüller 00005 * Copyright (C) 2011-2016 Christoph Redl 00006 * Copyright (C) 2015-2016 Tobias Kaminski 00007 * Copyright (C) 2015-2016 Antonius Weinzierl 00008 * 00009 * This file is part of dlvhex. 00010 * 00011 * dlvhex is free software; you can redistribute it and/or modify it 00012 * under the terms of the GNU Lesser General Public License as 00013 * published by the Free Software Foundation; either version 2.1 of 00014 * the License, or (at your option) any later version. 00015 * 00016 * dlvhex is distributed in the hope that it will be useful, but 00017 * WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00019 * Lesser General Public License for more details. 00020 * 00021 * You should have received a copy of the GNU Lesser General Public 00022 * License along with dlvhex; if not, write to the Free Software 00023 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 00024 * 02110-1301 USA. 00025 */ 00026 00037 #if !defined(_DLVHEX_ERROR_H) 00038 #define _DLVHEX_ERROR_H 00039 00040 #include "dlvhex2/PlatformDefinitions.h" 00041 00042 #include <string> 00043 #include <iosfwd> 00044 #include <stdexcept> 00045 00046 DLVHEX_NAMESPACE_BEGIN 00047 00051 class DLVHEX_EXPORT GeneralError : public std::runtime_error 00052 { 00053 public: 00054 00059 explicit 00060 GeneralError(const std::string& msg); 00061 00062 virtual ~GeneralError() throw() {} 00063 00072 virtual std::string 00073 getErrorMsg() const 00074 { 00075 return this->what(); 00076 } 00077 }; 00078 00082 class DLVHEX_EXPORT SyntaxError : public GeneralError 00083 { 00084 public: 00085 00091 explicit 00092 SyntaxError(const std::string& msg, 00093 const unsigned line = 0, 00094 const std::string& file = ""); 00095 00103 virtual ~SyntaxError() throw() {}; 00104 00110 virtual std::string 00111 getErrorMsg() const; 00112 00117 void 00118 setLine(unsigned line); 00119 00125 void 00126 setFile(const std::string& file); 00127 00128 private: 00130 unsigned line; 00132 std::string file; 00133 }; 00134 00138 class DLVHEX_EXPORT FatalError : public GeneralError 00139 { 00140 public: 00141 00150 explicit 00151 FatalError(const std::string& msg); 00152 00153 }; 00154 00158 class DLVHEX_EXPORT PluginError : public GeneralError 00159 { 00160 public: 00161 00165 explicit 00166 PluginError(const std::string& msg); 00167 00171 virtual ~PluginError() throw() {}; 00172 00180 void 00181 setContext(const std::string& ctx); 00182 00190 virtual std::string 00191 getErrorMsg() const; 00192 00193 private: 00195 std::string context; 00196 }; 00197 00198 // thrown to give error message about wrong usage of commandline of program or plugin 00199 // (you should give a usage help message when catching this) 00200 class UsageError: public FatalError 00201 { 00202 public: 00206 UsageError(const std::string& msg): 00207 FatalError(msg) {} 00209 virtual ~UsageError() throw() {} 00210 }; 00211 00212 DLVHEX_NAMESPACE_END 00213 #endif /* _DLVHEX_ERROR_H */ 00214 00215 00216 // vim:expandtab:ts=4:sw=4: 00217 // mode: C++ 00218 // End: