2013-05-21 18:02:42 +01:00
|
|
|
#ifndef LATAN_EXCEPTIONS_HPP_
|
|
|
|
#define LATAN_EXCEPTIONS_HPP_
|
|
|
|
|
|
|
|
#include <stdexcept>
|
|
|
|
#ifndef LATAN_GLOBAL_HPP_
|
|
|
|
#include <latan/Global.hpp>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define SRC_LOC strfrom<const char*>(__FUNCTION__) + " at "\
|
|
|
|
+ strfrom<const char*>(__FILE__) + ":" + strfrom<int>(__LINE__)
|
|
|
|
#define LATAN_ERROR(exc,msg) throw(Exceptions::exc(msg,SRC_LOC))
|
|
|
|
|
|
|
|
#define DECL_EXC(name,base) \
|
|
|
|
class name: public base\
|
|
|
|
{\
|
|
|
|
public:\
|
|
|
|
explicit name(std::string msg, std::string loc);\
|
|
|
|
}
|
|
|
|
|
|
|
|
LATAN_BEGIN_CPPDECL
|
|
|
|
|
|
|
|
namespace Exceptions
|
|
|
|
{
|
|
|
|
// logic errors
|
|
|
|
DECL_EXC(Logic,std::logic_error);
|
|
|
|
DECL_EXC(Implementation,Logic);
|
|
|
|
DECL_EXC(Range,Logic);
|
|
|
|
// runtime errors
|
|
|
|
DECL_EXC(Runtime,std::runtime_error);
|
2013-09-15 18:39:22 +01:00
|
|
|
DECL_EXC(Compilation,Runtime);
|
2014-01-22 15:57:47 +00:00
|
|
|
DECL_EXC(Io,Runtime);
|
2013-05-21 18:02:42 +01:00
|
|
|
DECL_EXC(Parsing,Runtime);
|
|
|
|
DECL_EXC(Syntax,Runtime);
|
|
|
|
}
|
|
|
|
|
|
|
|
LATAN_END_CPPDECL
|
|
|
|
|
|
|
|
#endif
|