-
Notifications
You must be signed in to change notification settings - Fork 14
/
error_macros.h
86 lines (69 loc) · 5.1 KB
/
error_macros.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
#ifndef ERROR_MACROS_H
#define ERROR_MACROS_H
#include <signal.h>
#include <iostream>
#if 0
#ifdef WINDOWS_ENABLED
#define RAISE_SIGNAL
#endif
#ifdef POSIX_ENABLED
#define RAISE_SIGNAL \
if (getenv("ABORT_ON_ERROR")) abort();
#endif
#endif
#define RAISE_SIGNAL
void _error_break_function();
#define ERR_FAIL_INDEX(m_index, m_size) \
{ \
if ((m_index) < 0 || (m_index) >= (m_size)) { \
std::cout << " *** ERROR *** " << __FILE__ << ":" << __LINE__ << " - " \
<< "index out of size: " << m_index << "(" << m_size << ")" << std::endl; \
_error_break_function(); \
RAISE_SIGNAL return; \
} \
}
#define ERR_FAIL_INDEX_V(m_index, m_size, m_retval) \
{ \
if ((m_index) < 0 || (m_index) >= (m_size)) { \
std::cout << " *** ERROR *** " << __FILE__ << ":" << __LINE__ << " - " \
<< "index out of size: " << m_index << "(" << m_size << ")" << std::endl; \
_error_break_function(); \
RAISE_SIGNAL return (m_retval); \
} \
}
#define ERR_FAIL_COND(m_cond) \
{ \
if (m_cond) { \
std::cout << " *** ERROR *** " << __FILE__ << ":" << __LINE__ << " - " << #m_cond " failed." << std::endl; \
_error_break_function(); \
RAISE_SIGNAL return; \
} \
}
#define ERR_FAIL_COND_V(m_cond, m_retval) \
{ \
if (m_cond) { \
std::cout << " *** ERROR *** " << __FILE__ << ":" << __LINE__ << " - " << #m_cond " failed." << std::endl; \
_error_break_function(); \
RAISE_SIGNAL return m_retval; \
} \
}
#define ERR_CONTINUE(m_cond) \
{ \
if (m_cond) { \
std::cout << " *** ERROR *** " << __FILE__ << ":" << __LINE__ << " - " << #m_cond " failed." << std::endl; \
_error_break_function(); \
RAISE_SIGNAL continue; \
} \
}
#define ERR_PRINT(m_string) \
{ \
std::cout << " *** ERROR *** " << __FILE__ << ":" << __LINE__ << " - " << m_string << std::endl; \
_error_break_function(); \
RAISE_SIGNAL \
}
#define WARN_PRINT(m_string) \
{ \
std::cout << " *** ERROR *** " << __FILE__ << ":" << __LINE__ << " - " << m_string << std::endl; \
RAISE_SIGNAL \
}
#endif