-
Notifications
You must be signed in to change notification settings - Fork 1
/
errormsg.cpp
64 lines (52 loc) · 1.09 KB
/
errormsg.cpp
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
#include "errormsg.h"
#include <stdio.h>
#include <stdlib.h>
namespace Error {
static int linenumber = 1;
static int errorCount = 0;
std::string filename;
void setFileName(const std::string& _filename)
{
filename = _filename;
}
int getLineNumber()
{
return linenumber;
}
int getErrorCount()
{
return errorCount;
}
void newline()
{
linenumber++;
}
void global_error(const std::string &message)
{
fputs((message + "\n").c_str(), stdout);
errorCount++;
}
void error(const std::string &message, int _linenumber)
{
printf("%s Error, line %d: %s\n",
filename.c_str(),
_linenumber > 0 ? _linenumber : Error::linenumber,
message.c_str());
errorCount++;
}
void warning(const std::string &message, int _linenumber)
{
printf("%s Warning, line %d: %s\n",
filename.c_str(),
_linenumber > 0 ? _linenumber : Error::linenumber,
message.c_str());
}
void fatalError(const std::string &message, int _linenumber)
{
printf("%s Internal error, line %d: %s\n",
filename.c_str(),
_linenumber > 0 ? _linenumber : Error::linenumber,
message.c_str());
exit(127);
}
}