2013-05-21 18:02:42 +01:00
|
|
|
#include <latan/Exceptions.hpp>
|
|
|
|
#include <latan/includes.hpp>
|
|
|
|
|
|
|
|
#ifndef ERR_PREF
|
2014-01-22 15:57:47 +00:00
|
|
|
#define ERR_PREF "[" + Env::name + " v" + Env::version + "] "
|
2013-05-21 18:02:42 +01:00
|
|
|
#endif
|
|
|
|
#ifndef ERR_SUFF
|
|
|
|
#define ERR_SUFF " (" + loc + ")"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define CONST_EXC(name,init) \
|
|
|
|
name::name(string msg, string loc)\
|
|
|
|
:init\
|
|
|
|
{}
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using namespace Latan;
|
|
|
|
using namespace Exceptions;
|
|
|
|
|
|
|
|
// logic errors
|
|
|
|
CONST_EXC(Logic,logic_error(ERR_PREF+msg+ERR_SUFF))
|
|
|
|
CONST_EXC(Implementation,Logic("implementation error: "+msg,loc))
|
|
|
|
CONST_EXC(Range,Logic("range error: "+msg,loc))
|
|
|
|
// runtime errors
|
|
|
|
CONST_EXC(Runtime,runtime_error(ERR_PREF+msg+ERR_SUFF))
|
2013-09-15 18:39:22 +01:00
|
|
|
CONST_EXC(Compilation,Runtime("compilation error: "+msg,loc))
|
2014-01-22 15:57:47 +00:00
|
|
|
CONST_EXC(Io,Runtime("IO error: "+msg,loc))
|
2013-05-21 18:02:42 +01:00
|
|
|
CONST_EXC(Parsing,Runtime(msg,loc))
|
|
|
|
CONST_EXC(Syntax,Runtime("syntax error: "+msg,loc))
|
|
|
|
|