29 #ifndef ERROR_MACROS_H 30 #define ERROR_MACROS_H 49 enum ErrorHandlerType {
55 typedef void (*ErrorHandlerFunc)(
void*,
const char*,
const char*,
int p_line,
const char *,
const char *,ErrorHandlerType p_type);
56 void _err_set_last_error(
const char* p_err);
57 void _err_clear_last_error();
61 ErrorHandlerFunc errfunc;
72 void _err_print_error(
const char* p_function,
const char* p_file,
int p_line,
const char *p_error,ErrorHandlerType p_type=ERR_HANDLER_ERROR);
75 #define _STR(m_x) #m_x 76 #define _MKSTR(m_x) _STR(m_x) 79 #define _FNL __FILE__":" 83 extern bool _err_error_exists;
88 #define ERR_EXPLAINC(m_reason) {_err_set_last_error(m_reason); _err_error_exists=true;} 89 #define ERR_EXPLAIN(m_string) {_err_set_last_error(String(m_string).utf8().get_data()); _err_error_exists=true;} 93 #define ERR_EXPLAIN( m_text ) 94 #define ERR_EXPLAINC( m_text ) 100 #define FUNCTION_STR __FUNCTION__ 102 #define FUNCTION_STR __FUNCTION__ 105 #define ERR_FAIL_INDEX(m_index,m_size) \ 106 do {if ((m_index)<0 || (m_index)>=(m_size)) { \ 107 _err_print_error(FUNCTION_STR,__FILE__,__LINE__,"Index " _STR(m_index)" out of size (" _STR(m_size)")."); \ 109 } else _err_error_exists=false; } while(0); \ 116 #define ERR_FAIL_INDEX_V(m_index,m_size,m_retval) \ 117 do {if ((m_index)<0 || (m_index)>=(m_size)) { \ 118 _err_print_error(FUNCTION_STR,__FILE__,__LINE__,"Index " _STR(m_index)" out of size (" _STR(m_size)")."); \ 120 } else _err_error_exists=false;} while (0); 126 #define ERR_FAIL_NULL(m_param) \ 127 { if ( !m_param ) { \ 128 _err_print_error(FUNCTION_STR,__FILE__,__LINE__,"Parameter ' " _STR(m_param)" ' is null."); \ 130 }else _err_error_exists=false; } \ 133 #define ERR_FAIL_NULL_V(m_param,m_retval) \ 134 { if ( !m_param ) { \ 135 _err_print_error(FUNCTION_STR,__FILE__,__LINE__,"Parameter ' " _STR(m_param)" ' is null."); \ 137 }else _err_error_exists=false; } \ 143 #define ERR_FAIL_COND(m_cond) \ 145 _err_print_error(FUNCTION_STR,__FILE__,__LINE__,"Condition ' " _STR(m_cond)" ' is true."); \ 147 }else _err_error_exists=false; } \ 155 #define ERR_FAIL_COND_V(m_cond,m_retval) \ 157 _err_print_error(FUNCTION_STR,__FILE__,__LINE__,"Condition ' " _STR(m_cond)" ' is true. returned: " _STR(m_retval)); \ 159 }else _err_error_exists=false; } \ 165 #define ERR_CONTINUE(m_cond) \ 167 _err_print_error(FUNCTION_STR,__FILE__,__LINE__,"Condition ' " _STR(m_cond)" ' is true. Continuing..:"); \ 169 } else _err_error_exists=false;} \ 175 #define ERR_BREAK(m_cond) \ 177 _err_print_error(FUNCTION_STR,__FILE__,__LINE__,"Condition ' " _STR(m_cond)" ' is true. Breaking..:"); \ 179 } else _err_error_exists=false;} \ 186 _err_print_error(FUNCTION_STR,__FILE__,__LINE__,"Method/Function Failed."); \ 187 _err_error_exists=false;\ 194 #define ERR_FAIL_V(m_value) \ 196 _err_print_error(FUNCTION_STR,__FILE__,__LINE__,"Method/Function Failed, returning: " __STR(m_value)); \ 197 _err_error_exists=false; \ 204 #define ERR_PRINT(m_string) \ 206 _err_print_error(FUNCTION_STR,__FILE__,__LINE__,m_string); \ 207 _err_error_exists=false;\ 210 #define ERR_PRINTS(m_string) \ 212 _err_print_error(FUNCTION_STR,__FILE__,__LINE__,String(m_string).utf8().get_data()); \ 213 _err_error_exists=false;\ 219 #define WARN_PRINT(m_string) \ 221 _err_print_error(FUNCTION_STR,__FILE__,__LINE__,m_string,ERR_HANDLER_WARNING); \ 222 _err_error_exists=false;\ Definition: error_macros.h:59