diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2019-11-11 13:27:51 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-11 13:27:51 +0100 |
commit | 6b1628f9fcc50dc16af08c2b87f27108ff6e15c5 (patch) | |
tree | 5bb1ef20e714dc1d9a8421ee2419036534d2f230 /core/error_macros.cpp | |
parent | 5c038acdc159708113fdc911c44abf1d6dcdbdf7 (diff) | |
parent | 83069a3c0f01507acd24672c90b24c9eba868aba (diff) |
Merge pull request #33517 from madmiraal/fix-_MSG-macros
Send *_MSG macros' explanations directly to the _err_print_error().
Diffstat (limited to 'core/error_macros.cpp')
-rw-r--r-- | core/error_macros.cpp | 52 |
1 files changed, 25 insertions, 27 deletions
diff --git a/core/error_macros.cpp b/core/error_macros.cpp index eda6b9cbbb..55a215cfb6 100644 --- a/core/error_macros.cpp +++ b/core/error_macros.cpp @@ -34,25 +34,8 @@ #include "core/ustring.h" #include "os/os.h" -bool _err_error_exists = false; - static ErrorHandlerList *error_handler_list = NULL; -void _err_set_last_error(const char *p_err) { - - OS::get_singleton()->set_last_error(p_err); -} - -void _err_set_last_error(const String &p_err) { - - _err_set_last_error(p_err.utf8().get_data()); -} - -void _err_clear_last_error() { - - OS::get_singleton()->clear_last_error(); -} - void add_error_handler(ErrorHandlerList *p_handler) { _global_lock(); @@ -86,32 +69,47 @@ 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_print_error(p_function, p_file, p_line, p_error, "", p_type); +} - OS::get_singleton()->print_error(p_function, p_file, p_line, p_error, _err_error_exists ? OS::get_singleton()->get_last_error() : "", (Logger::ErrorType)p_type); +void _err_print_error(const char *p_function, const char *p_file, int p_line, const String &p_error, ErrorHandlerType p_type) { + _err_print_error(p_function, p_file, p_line, p_error.utf8().get_data(), "", p_type); +} + +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, _err_error_exists ? OS::get_singleton()->get_last_error() : "", p_type); + l->errfunc(l->userdata, p_function, p_file, p_line, p_error, p_message, p_type); l = l->next; } _global_unlock(); +} - if (_err_error_exists) { - OS::get_singleton()->clear_last_error(); - _err_error_exists = false; - } +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 String &p_error, ErrorHandlerType p_type) { - _err_print_error(p_function, p_file, p_line, p_error.utf8().get_data(), 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, bool fatal) { +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); } |