Send m_msg directly to _err_print_error().
This commit is contained in:
parent
94f00eb6c5
commit
b7fdac60f1
2 changed files with 142 additions and 116 deletions
|
@ -109,9 +109,40 @@ void _err_print_error(const char *p_function, const char *p_file, int p_line, co
|
|||
_err_print_error(p_function, p_file, p_line, p_error.utf8().get_data(), p_type);
|
||||
}
|
||||
|
||||
void _err_print_index_error(const char *p_function, const char *p_file, int p_line, int64_t p_index, int64_t p_size, const char *p_index_str, const char *p_size_str, bool fatal) {
|
||||
void _err_print_error(const char *p_function, const char *p_file, int p_line, const char *p_error, const char *p_message, ErrorHandlerType p_type) {
|
||||
|
||||
OS::get_singleton()->print_error(p_function, p_file, p_line, p_error, p_message, (Logger::ErrorType)p_type);
|
||||
|
||||
_global_lock();
|
||||
ErrorHandlerList *l = error_handler_list;
|
||||
while (l) {
|
||||
|
||||
l->errfunc(l->userdata, p_function, p_file, p_line, p_error, p_message, p_type);
|
||||
l = l->next;
|
||||
}
|
||||
|
||||
_global_unlock();
|
||||
}
|
||||
|
||||
void _err_print_error(const char *p_function, const char *p_file, int p_line, const String &p_error, const char *p_message, ErrorHandlerType p_type) {
|
||||
_err_print_error(p_function, p_file, p_line, p_error.utf8().get_data(), p_message, p_type);
|
||||
}
|
||||
|
||||
void _err_print_error(const char *p_function, const char *p_file, int p_line, const char *p_error, const String &p_message, ErrorHandlerType p_type) {
|
||||
_err_print_error(p_function, p_file, p_line, p_error, p_message.utf8().get_data(), p_type);
|
||||
}
|
||||
|
||||
void _err_print_error(const char *p_function, const char *p_file, int p_line, const String &p_error, const String &p_message, ErrorHandlerType p_type) {
|
||||
_err_print_error(p_function, p_file, p_line, p_error.utf8().get_data(), p_message.utf8().get_data(), p_type);
|
||||
}
|
||||
|
||||
void _err_print_index_error(const char *p_function, const char *p_file, int p_line, int64_t p_index, int64_t p_size, const char *p_index_str, const char *p_size_str, const char *p_message, bool fatal) {
|
||||
|
||||
String fstr(fatal ? "FATAL: " : "");
|
||||
String err(fstr + "Index " + p_index_str + "=" + itos(p_index) + " out of size (" + p_size_str + "=" + itos(p_size) + ")");
|
||||
_err_print_error(p_function, p_file, p_line, err.utf8().get_data());
|
||||
_err_print_error(p_function, p_file, p_line, err.utf8().get_data(), p_message);
|
||||
}
|
||||
|
||||
void _err_print_index_error(const char *p_function, const char *p_file, int p_line, int64_t p_index, int64_t p_size, const char *p_index_str, const char *p_size_str, const String &p_message, bool fatal) {
|
||||
_err_print_index_error(p_function, p_file, p_line, p_index, p_size, p_index_str, p_size_str, p_message.utf8().get_data(), fatal);
|
||||
}
|
||||
|
|
|
@ -80,7 +80,12 @@ void remove_error_handler(ErrorHandlerList *p_handler);
|
|||
|
||||
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);
|
||||
void _err_print_error(const char *p_function, const char *p_file, int p_line, const String &p_error, ErrorHandlerType p_type = ERR_HANDLER_ERROR);
|
||||
void _err_print_index_error(const char *p_function, const char *p_file, int p_line, int64_t p_index, int64_t p_size, const char *p_index_str, const char *p_size_str, bool fatal = false);
|
||||
void _err_print_error(const char *p_function, const char *p_file, int p_line, const char *p_error, const char *p_message, ErrorHandlerType p_type = ERR_HANDLER_ERROR);
|
||||
void _err_print_error(const char *p_function, const char *p_file, int p_line, const String &p_error, const char *p_message, ErrorHandlerType p_type = ERR_HANDLER_ERROR);
|
||||
void _err_print_error(const char *p_function, const char *p_file, int p_line, const char *p_error, const String &p_message, ErrorHandlerType p_type = ERR_HANDLER_ERROR);
|
||||
void _err_print_error(const char *p_function, const char *p_file, int p_line, const String &p_error, const String &p_message, ErrorHandlerType p_type = ERR_HANDLER_ERROR);
|
||||
void _err_print_index_error(const char *p_function, const char *p_file, int p_line, int64_t p_index, int64_t p_size, const char *p_index_str, const char *p_size_str, const char *p_message = "", bool fatal = false);
|
||||
void _err_print_index_error(const char *p_function, const char *p_file, int p_line, int64_t p_index, int64_t p_size, const char *p_index_str, const char *p_size_str, const String &p_message, bool fatal = false);
|
||||
|
||||
#ifndef _STR
|
||||
#define _STR(m_x) #m_x
|
||||
|
@ -146,8 +151,7 @@ extern bool _err_error_exists;
|
|||
#define ERR_FAIL_INDEX_MSG(m_index, m_size, m_msg) \
|
||||
do { \
|
||||
if (unlikely((m_index) < 0 || (m_index) >= (m_size))) { \
|
||||
ERR_EXPLAIN(m_msg); \
|
||||
_err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size)); \
|
||||
_err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size), m_msg); \
|
||||
return; \
|
||||
} \
|
||||
_err_error_exists = false; \
|
||||
|
@ -170,8 +174,7 @@ extern bool _err_error_exists;
|
|||
#define ERR_FAIL_INDEX_V_MSG(m_index, m_size, m_retval, m_msg) \
|
||||
do { \
|
||||
if (unlikely((m_index) < 0 || (m_index) >= (m_size))) { \
|
||||
ERR_EXPLAIN(m_msg); \
|
||||
_err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size)); \
|
||||
_err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size), m_msg); \
|
||||
return m_retval; \
|
||||
} \
|
||||
_err_error_exists = false; \
|
||||
|
@ -194,8 +197,7 @@ extern bool _err_error_exists;
|
|||
#define ERR_FAIL_UNSIGNED_INDEX_V_MSG(m_index, m_size, m_retval, m_msg) \
|
||||
do { \
|
||||
if (unlikely((m_index) >= (m_size))) { \
|
||||
ERR_EXPLAIN(m_msg); \
|
||||
_err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size)); \
|
||||
_err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size), m_msg); \
|
||||
return m_retval; \
|
||||
} \
|
||||
_err_error_exists = false; \
|
||||
|
@ -207,7 +209,7 @@ extern bool _err_error_exists;
|
|||
#define CRASH_BAD_INDEX(m_index, m_size) \
|
||||
do { \
|
||||
if (unlikely((m_index) < 0 || (m_index) >= (m_size))) { \
|
||||
_err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size), true); \
|
||||
_err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size), "", true); \
|
||||
GENERATE_TRAP \
|
||||
} \
|
||||
} while (0); // (*)
|
||||
|
@ -215,8 +217,7 @@ extern bool _err_error_exists;
|
|||
#define CRASH_BAD_INDEX_MSG(m_index, m_size, m_msg) \
|
||||
do { \
|
||||
if (unlikely((m_index) < 0 || (m_index) >= (m_size))) { \
|
||||
ERR_EXPLAIN(m_msg); \
|
||||
_err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size), true); \
|
||||
_err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size), m_msg, true); \
|
||||
GENERATE_TRAP \
|
||||
} \
|
||||
} while (0); // (*)
|
||||
|
@ -237,8 +238,7 @@ extern bool _err_error_exists;
|
|||
#define ERR_FAIL_NULL_MSG(m_param, m_msg) \
|
||||
{ \
|
||||
if (unlikely(!m_param)) { \
|
||||
ERR_EXPLAIN(m_msg); \
|
||||
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Parameter ' " _STR(m_param) " ' is null."); \
|
||||
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Parameter ' " _STR(m_param) " ' is null.", m_msg); \
|
||||
return; \
|
||||
} \
|
||||
_err_error_exists = false; \
|
||||
|
@ -256,8 +256,7 @@ extern bool _err_error_exists;
|
|||
#define ERR_FAIL_NULL_V_MSG(m_param, m_retval, m_msg) \
|
||||
{ \
|
||||
if (unlikely(!m_param)) { \
|
||||
ERR_EXPLAIN(m_msg); \
|
||||
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Parameter ' " _STR(m_param) " ' is null."); \
|
||||
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Parameter ' " _STR(m_param) " ' is null.", m_msg); \
|
||||
return m_retval; \
|
||||
} \
|
||||
_err_error_exists = false; \
|
||||
|
@ -279,8 +278,7 @@ extern bool _err_error_exists;
|
|||
#define ERR_FAIL_COND_MSG(m_cond, m_msg) \
|
||||
{ \
|
||||
if (unlikely(m_cond)) { \
|
||||
ERR_EXPLAIN(m_msg); \
|
||||
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition ' " _STR(m_cond) " ' is true."); \
|
||||
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition ' " _STR(m_cond) " ' is true.", m_msg); \
|
||||
return; \
|
||||
} \
|
||||
_err_error_exists = false; \
|
||||
|
@ -300,8 +298,7 @@ extern bool _err_error_exists;
|
|||
#define CRASH_COND_MSG(m_cond, m_msg) \
|
||||
{ \
|
||||
if (unlikely(m_cond)) { \
|
||||
ERR_EXPLAIN(m_msg); \
|
||||
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "FATAL: Condition ' " _STR(m_cond) " ' is true."); \
|
||||
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "FATAL: Condition ' " _STR(m_cond) " ' is true.", m_msg); \
|
||||
GENERATE_TRAP \
|
||||
} \
|
||||
}
|
||||
|
@ -324,8 +321,7 @@ extern bool _err_error_exists;
|
|||
#define ERR_FAIL_COND_V_MSG(m_cond, m_retval, m_msg) \
|
||||
{ \
|
||||
if (unlikely(m_cond)) { \
|
||||
ERR_EXPLAIN(m_msg); \
|
||||
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition ' " _STR(m_cond) " ' is true. returned: " _STR(m_retval)); \
|
||||
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition ' " _STR(m_cond) " ' is true. returned: " _STR(m_retval), m_msg); \
|
||||
return m_retval; \
|
||||
} \
|
||||
_err_error_exists = false; \
|
||||
|
@ -347,8 +343,7 @@ extern bool _err_error_exists;
|
|||
#define ERR_CONTINUE_MSG(m_cond, m_msg) \
|
||||
{ \
|
||||
if (unlikely(m_cond)) { \
|
||||
ERR_EXPLAIN(m_msg); \
|
||||
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition ' " _STR(m_cond) " ' is true. Continuing..:"); \
|
||||
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition ' " _STR(m_cond) " ' is true. Continuing..:", m_msg); \
|
||||
continue; \
|
||||
} \
|
||||
_err_error_exists = false; \
|
||||
|
@ -370,8 +365,7 @@ extern bool _err_error_exists;
|
|||
#define ERR_BREAK_MSG(m_cond, m_msg) \
|
||||
{ \
|
||||
if (unlikely(m_cond)) { \
|
||||
ERR_EXPLAIN(m_msg); \
|
||||
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition ' " _STR(m_cond) " ' is true. Breaking..:"); \
|
||||
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition ' " _STR(m_cond) " ' is true. Breaking..:", m_msg); \
|
||||
break; \
|
||||
} \
|
||||
_err_error_exists = false; \
|
||||
|
@ -389,8 +383,9 @@ extern bool _err_error_exists;
|
|||
|
||||
#define ERR_FAIL_MSG(m_msg) \
|
||||
{ \
|
||||
ERR_EXPLAIN(m_msg); \
|
||||
ERR_FAIL(); \
|
||||
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Method/Function Failed.", m_msg); \
|
||||
_err_error_exists = false; \
|
||||
return; \
|
||||
}
|
||||
|
||||
/** Print an error string and return with value
|
||||
|
@ -405,8 +400,9 @@ extern bool _err_error_exists;
|
|||
|
||||
#define ERR_FAIL_V_MSG(m_value, m_msg) \
|
||||
{ \
|
||||
ERR_EXPLAIN(m_msg); \
|
||||
ERR_FAIL_V(m_value); \
|
||||
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Method/Function Failed, returning: " __STR(m_value), m_msg); \
|
||||
_err_error_exists = false; \
|
||||
return m_value; \
|
||||
}
|
||||
|
||||
/** Use this one if there is no sensible fallback, that is, the error is unrecoverable.
|
||||
|
@ -420,8 +416,8 @@ extern bool _err_error_exists;
|
|||
|
||||
#define CRASH_NOW_MSG(m_msg) \
|
||||
{ \
|
||||
ERR_EXPLAIN(m_msg); \
|
||||
CRASH_NOW(); \
|
||||
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "FATAL: Method/Function Failed.", m_msg); \
|
||||
GENERATE_TRAP \
|
||||
}
|
||||
|
||||
/** Print an error string.
|
||||
|
@ -488,8 +484,7 @@ extern bool _err_error_exists;
|
|||
{ \
|
||||
static volatile bool warning_shown = false; \
|
||||
if (!warning_shown) { \
|
||||
ERR_EXPLAIN(m_msg); \
|
||||
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "This method has been deprecated and will be removed in the future", ERR_HANDLER_WARNING); \
|
||||
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "This method has been deprecated and will be removed in the future", m_msg, ERR_HANDLER_WARNING); \
|
||||
_err_error_exists = false; \
|
||||
warning_shown = true; \
|
||||
} \
|
||||
|
|
Loading…
Reference in a new issue