-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathZError.h
70 lines (55 loc) · 1.3 KB
/
ZError.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
#pragma once
enum ZErrorTypes{
ZBadConversionError,
ZOperationNotSupported,
ZDivisionByZeroException,
ZWrongNumberOfArguments,
ZWrongNumberInList,
ZNotDefined
};
#define OUT_STRM std::cout
class ZError
{
public:
static void DoWrite(ZChar* mess)
{
std::cout<<mess;
}
template <ZErrorTypes T>
static void Throw()
{
OUT_STRM << (_ZC("Error : "));
Speak<T>();
OUT_STRM << (_ZC(" , at Line : ")) << Lnum() << " At Character : " << Cnum() << std::endl;
exit(1);
}
static int Lnum();
static int Cnum();
template <ZErrorTypes T>
static void Speak()
{}
template <>
static void Speak<ZBadConversionError>(){
OUT_STRM<<(_ZC("Un-expected type passed"));
}
template <>
static void Speak<ZOperationNotSupported>(){
OUT_STRM<<(_ZC("Operation not supported on types"));
}
template <>
static void Speak<ZDivisionByZeroException>(){
OUT_STRM<<(_ZC("Division by Zero"));
}
template <>
static void Speak<ZWrongNumberOfArguments>(){
OUT_STRM<<(_ZC("Wrong number of passed arguments"));
}
template <>
static void Speak<ZWrongNumberInList>(){
OUT_STRM<<(_ZC("Wrong number of arguments passed in the List"));
}
template <>
static void Speak<ZNotDefined>(){
OUT_STRM<<(_ZC("Not Defined Element"));
}
};