-
Notifications
You must be signed in to change notification settings - Fork 0
/
ml_exception.h
103 lines (66 loc) · 1.24 KB
/
ml_exception.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/**
* @file ml_exception.h
* @brief
* @author malin [email protected]
* @date 2015年04月24日 星期五 16时20分54秒
* @version
* @note
*/
#ifndef __ML_INTERNAL_EXCEPTION
#define __ML_INTERNAL_EXCEPTION
#include "ml_config.h"
__ML_BEGIN_NAMESPACE
// root class for exceptions
class exception
{
public:
virtual const char *what() const
{
return "";
}
virtual ~exception() {}
};
// logic_error exceptions
class logic_error : public exception
{
public:
logic_error(const char *str) : Message(str) {}
const char *what() const
{
return Message;
}
private:
const char *Message;
};
class out_of_range : public logic_error
{
public:
out_of_range(const char *str) : logic_error(str) {}
};
// runtime_error exceptions
class runtime_error : public exception
{
public:
runtime_error(const char *str) : Message(str) {}
const char *what() const
{
return Message;
}
private:
const char *Message;
};
class underflow_error : public runtime_error
{
public:
underflow_error(const char *str) : runtime_error(str) {}
};
// bad_alloc
class bad_alloc : public exception
{
public:
bad_alloc(const char *str) : Message(str) {}
private:
const char *Message;
};
__ML_END_NAMESPACE
#endif // __ML_INTERNAL_EXCEPTION