1
0
mirror of https://github.com/aportelli/LatAnalyze.git synced 2024-11-10 00:45:36 +00:00

warning macro added

This commit is contained in:
Antonin Portelli 2014-02-18 18:09:02 +00:00
parent 7699dad913
commit 364c56209a
2 changed files with 12 additions and 5 deletions

View File

@ -20,9 +20,6 @@
#include <latan/Exceptions.hpp>
#include <latan/includes.hpp>
#ifndef ERR_PREF
#define ERR_PREF "[" + Env::name + " v" + Env::version + "] "
#endif
#ifndef ERR_SUFF
#define ERR_SUFF " (" + loc + ")"
#endif
@ -36,14 +33,18 @@ using namespace std;
using namespace Latan;
using namespace Exceptions;
// prefix for messages
const string Latan::Exceptions::prefix = "[" + strFrom(PACKAGE_NAME) + " v"
+ strFrom(PACKAGE_VERSION) + "] ";
// logic errors
CONST_EXC(Logic, logic_error(ERR_PREF + msg + ERR_SUFF))
CONST_EXC(Logic, logic_error(prefix + msg + ERR_SUFF))
CONST_EXC(Definition, Logic("definition error: " + msg, loc))
CONST_EXC(Implementation, Logic("implementation error: " + msg, loc))
CONST_EXC(Range, Logic("range error: " + msg, loc))
CONST_EXC(Size, Logic("size error: " + msg, loc))
// runtime errors
CONST_EXC(Runtime, runtime_error(ERR_PREF + msg + ERR_SUFF))
CONST_EXC(Runtime, runtime_error(prefix + msg + ERR_SUFF))
CONST_EXC(Compilation, Runtime("compilation error: " + msg, loc))
CONST_EXC(Io, Runtime("IO error: " + msg, loc))
CONST_EXC(Parsing, Runtime(msg, loc))

View File

@ -28,6 +28,9 @@
#define SRC_LOC strFrom(__FUNCTION__) + " at " + strFrom(__FILE__) + ":"\
+ strFrom(__LINE__)
#define LATAN_ERROR(exc,msg) throw(Exceptions::exc(msg, SRC_LOC))
#define LATAN_WARNING(msg) \
std::cerr << Latan::Exceptions::prefix << "warning: " << msg\
<< " (" << SRC_LOC << ")" << std::endl
#define DECL_EXC(name, base) \
class name: public base\
@ -40,6 +43,9 @@ BEGIN_NAMESPACE
namespace Exceptions
{
// prefix for messages
extern const std::string prefix;
// logic errors
DECL_EXC(Logic, std::logic_error);
DECL_EXC(Definition, Logic);