mirror of
				https://github.com/aportelli/LatAnalyze.git
				synced 2025-10-26 04:59:33 +00:00 
			
		
		
		
	warning macro added
This commit is contained in:
		| @@ -20,9 +20,6 @@ | |||||||
| #include <latan/Exceptions.hpp> | #include <latan/Exceptions.hpp> | ||||||
| #include <latan/includes.hpp> | #include <latan/includes.hpp> | ||||||
|  |  | ||||||
| #ifndef ERR_PREF |  | ||||||
| #define ERR_PREF "[" + Env::name + " v" + Env::version + "] " |  | ||||||
| #endif |  | ||||||
| #ifndef ERR_SUFF | #ifndef ERR_SUFF | ||||||
| #define ERR_SUFF " (" + loc + ")" | #define ERR_SUFF " (" + loc + ")" | ||||||
| #endif | #endif | ||||||
| @@ -36,14 +33,18 @@ using namespace std; | |||||||
| using namespace Latan; | using namespace Latan; | ||||||
| using namespace Exceptions; | using namespace Exceptions; | ||||||
|  |  | ||||||
|  | // prefix for messages | ||||||
|  | const string Latan::Exceptions::prefix = "[" + strFrom(PACKAGE_NAME) + " v" | ||||||
|  |                                          + strFrom(PACKAGE_VERSION) + "] "; | ||||||
|  |  | ||||||
| // logic errors | // 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(Definition, Logic("definition error: " + msg, loc)) | ||||||
| CONST_EXC(Implementation, Logic("implementation error: " + msg, loc)) | CONST_EXC(Implementation, Logic("implementation error: " + msg, loc)) | ||||||
| CONST_EXC(Range, Logic("range error: " + msg, loc)) | CONST_EXC(Range, Logic("range error: " + msg, loc)) | ||||||
| CONST_EXC(Size, Logic("size error: " + msg, loc)) | CONST_EXC(Size, Logic("size error: " + msg, loc)) | ||||||
| // runtime errors | // 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(Compilation, Runtime("compilation error: " + msg, loc)) | ||||||
| CONST_EXC(Io, Runtime("IO error: " + msg, loc)) | CONST_EXC(Io, Runtime("IO error: " + msg, loc)) | ||||||
| CONST_EXC(Parsing, Runtime(msg, loc)) | CONST_EXC(Parsing, Runtime(msg, loc)) | ||||||
|   | |||||||
| @@ -28,6 +28,9 @@ | |||||||
| #define SRC_LOC strFrom(__FUNCTION__) + " at " + strFrom(__FILE__) + ":"\ | #define SRC_LOC strFrom(__FUNCTION__) + " at " + strFrom(__FILE__) + ":"\ | ||||||
|                 + strFrom(__LINE__) |                 + strFrom(__LINE__) | ||||||
| #define LATAN_ERROR(exc,msg) throw(Exceptions::exc(msg, SRC_LOC)) | #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) \ | #define DECL_EXC(name, base) \ | ||||||
| class name: public base\ | class name: public base\ | ||||||
| @@ -40,6 +43,9 @@ BEGIN_NAMESPACE | |||||||
|  |  | ||||||
| namespace Exceptions | namespace Exceptions | ||||||
| { | { | ||||||
|  |     // prefix for messages | ||||||
|  |     extern const std::string prefix; | ||||||
|  |      | ||||||
|     // logic errors |     // logic errors | ||||||
|     DECL_EXC(Logic, std::logic_error); |     DECL_EXC(Logic, std::logic_error); | ||||||
|     DECL_EXC(Definition, Logic); |     DECL_EXC(Definition, Logic); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user