2014-02-06 18:52:13 +00:00
|
|
|
/*
|
|
|
|
* Exceptions.hpp, part of LatAnalyze 3
|
|
|
|
*
|
2020-01-13 09:57:06 +00:00
|
|
|
* Copyright (C) 2013 - 2020 Antonin Portelli
|
2014-02-06 18:52:13 +00:00
|
|
|
*
|
|
|
|
* LatAnalyze 3 is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* LatAnalyze 3 is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with LatAnalyze 3. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef Latan_Exceptions_hpp_
|
|
|
|
#define Latan_Exceptions_hpp_
|
2013-05-21 18:02:42 +01:00
|
|
|
|
|
|
|
#include <stdexcept>
|
|
|
|
#ifndef LATAN_GLOBAL_HPP_
|
2014-03-13 18:51:01 +00:00
|
|
|
#include <LatAnalyze/Global.hpp>
|
2013-05-21 18:02:42 +01:00
|
|
|
#endif
|
|
|
|
|
2014-02-10 11:22:27 +00:00
|
|
|
#define SRC_LOC strFrom(__FUNCTION__) + " at " + strFrom(__FILE__) + ":"\
|
|
|
|
+ strFrom(__LINE__)
|
|
|
|
#define LATAN_ERROR(exc,msg) throw(Exceptions::exc(msg, SRC_LOC))
|
2014-02-18 18:09:02 +00:00
|
|
|
#define LATAN_WARNING(msg) \
|
2014-02-20 22:54:11 +00:00
|
|
|
std::cerr << Env::msgPrefix << "warning: " << msg\
|
2014-02-18 18:09:02 +00:00
|
|
|
<< " (" << SRC_LOC << ")" << std::endl
|
2013-05-21 18:02:42 +01:00
|
|
|
|
2014-02-06 18:07:27 +00:00
|
|
|
#define DECL_EXC(name, base) \
|
2013-05-21 18:02:42 +01:00
|
|
|
class name: public base\
|
|
|
|
{\
|
|
|
|
public:\
|
2014-03-03 14:21:37 +00:00
|
|
|
name(std::string msg, std::string loc);\
|
2013-05-21 18:02:42 +01:00
|
|
|
}
|
|
|
|
|
2015-01-28 17:15:05 +00:00
|
|
|
BEGIN_LATAN_NAMESPACE
|
2013-05-21 18:02:42 +01:00
|
|
|
|
|
|
|
namespace Exceptions
|
|
|
|
{
|
|
|
|
// logic errors
|
2014-02-06 18:07:27 +00:00
|
|
|
DECL_EXC(Logic, std::logic_error);
|
|
|
|
DECL_EXC(Definition, Logic);
|
|
|
|
DECL_EXC(Implementation, Logic);
|
|
|
|
DECL_EXC(Range, Logic);
|
|
|
|
DECL_EXC(Size, Logic);
|
2013-05-21 18:02:42 +01:00
|
|
|
// runtime errors
|
2014-02-06 18:07:27 +00:00
|
|
|
DECL_EXC(Runtime, std::runtime_error);
|
2016-04-12 20:10:37 +01:00
|
|
|
DECL_EXC(Argument, Runtime);
|
2014-02-06 18:07:27 +00:00
|
|
|
DECL_EXC(Compilation, Runtime);
|
|
|
|
DECL_EXC(Io, Runtime);
|
2014-03-03 12:41:48 +00:00
|
|
|
DECL_EXC(Memory, Runtime);
|
2014-02-06 18:07:27 +00:00
|
|
|
DECL_EXC(Parsing, Runtime);
|
|
|
|
DECL_EXC(Program, Runtime);
|
|
|
|
DECL_EXC(Syntax, Runtime);
|
2014-02-10 11:22:27 +00:00
|
|
|
DECL_EXC(System, Runtime);
|
2013-05-21 18:02:42 +01:00
|
|
|
}
|
|
|
|
|
2015-01-28 17:15:05 +00:00
|
|
|
END_LATAN_NAMESPACE
|
2013-05-21 18:02:42 +01:00
|
|
|
|
2014-02-06 18:52:13 +00:00
|
|
|
#endif // Latan_Exceptions_hpp_
|