forked from hiraditya/cpp2cxx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ExceptionHandler.h
75 lines (64 loc) · 1.68 KB
/
ExceptionHandler.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#ifndef EXCEPTIONHANDLER_H
#define EXCEPTIONHANDLER_H
/**
* @file ExceptionHandler.h
* @brief class that defines various exceptions other than the
* std::exception which can be used in case of exception
* @version 1.0
* @author Aditya Kumar
* @note
* compiles with g++-4.5 or higher,
* for compiling pass -std=c++0x to the compiler
*/
#include "DemacBoostWaveIncludes.h"
#include <string>
#include <sstream>
/**
* @class ExceptionHandler
* To handle exceptions
* @TODO: Change the name to exception
* Handle exception thrown as ExceptionHandler(const PPMacro* mac, std::string msg)
*/
class ExceptionHandler {
public:
ExceptionHandler() : message("Unknown Exception")
{}
ExceptionHandler(int i) : error_code(i)
{}
ExceptionHandler(std::string msg) : message(msg)
{}
ExceptionHandler(token_type const& tok, std::string msg)
{
std::stringstream err_msg;
err_msg << " - note: ";
err_msg //<<tok.get_position().get_file()<<":"
<<tok.get_position().get_line()<<":"
<<tok.get_position().get_column()<<": ";
err_msg << msg;
message = err_msg.str();
}
/*
ExceptionHandler(const PPMacro* mac, std::string msg)
{
std::stringstream err_msg;
token_type tok = mac->get_identifier();
err_msg <<tok.get_position().get_file()<<":"
<<tok.get_position().get_line()<<":"
<<tok.get_position().get_column()<<":";
err_msg << msg;
message = err_msg.str();
}
*/
inline std::string GetMessage()
{
return message;
}
inline int GetErrorCode()
{
return error_code;
}
private:
std::string message;
int error_code;
};
#endif /*EXCEPTIONHANDLER_H*/