diff options
| author | George L. Albany <Megacake1234@gmail.com> | 2024-10-27 13:25:03 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-27 13:25:03 +0000 |
| commit | 6e3e9dfb9857b751f59fd4b40c55e9262ff5a864 (patch) | |
| tree | d064b49a4766ab69a0ac6e195868ad4b3443bab3 /core/error | |
| parent | bec9ffacba1385b0ba808f6dbb66abb7dc53639d (diff) | |
| parent | 953af98c795066a5a450a3401cc8a4fbc6c12620 (diff) | |
| download | redot-engine-6e3e9dfb9857b751f59fd4b40c55e9262ff5a864.tar.gz | |
Merge pull request #814 from Spartan322/merge/61accf0
Merge commit godotengine/godot@61accf0
Diffstat (limited to 'core/error')
| -rw-r--r-- | core/error/error_macros.cpp | 22 | ||||
| -rw-r--r-- | core/error/error_macros.h | 1 |
2 files changed, 23 insertions, 0 deletions
diff --git a/core/error/error_macros.cpp b/core/error/error_macros.cpp index e11cf40511..2a6dfe67d8 100644 --- a/core/error/error_macros.cpp +++ b/core/error/error_macros.cpp @@ -109,6 +109,28 @@ void _err_print_error(const char *p_function, const char *p_file, int p_line, co _global_unlock(); } +// For printing errors when we may crash at any point, so we must flush ASAP a lot of lines +// but we don't want to make it noisy by printing lots of file & line info (because it's already +// been printing by a preceding _err_print_error). +void _err_print_error_asap(const String &p_error, ErrorHandlerType p_type) { + if (OS::get_singleton()) { + OS::get_singleton()->printerr("ERROR: %s\n", p_error.utf8().get_data()); + } else { + // Fallback if errors happen before OS init or after it's destroyed. + const char *err_details = p_error.utf8().get_data(); + fprintf(stderr, "ERROR: %s\n", err_details); + } + + _global_lock(); + ErrorHandlerList *l = error_handler_list; + while (l) { + l->errfunc(l->userdata, "", "", 0, p_error.utf8().get_data(), "", false, p_type); + l = l->next; + } + + _global_unlock(); +} + // Errors with message. (All combinations of p_error and p_message as String or char*.) void _err_print_error(const char *p_function, const char *p_file, int p_line, const String &p_error, const char *p_message, bool p_editor_notify, ErrorHandlerType p_type) { _err_print_error(p_function, p_file, p_line, p_error.utf8().get_data(), p_message, p_editor_notify, p_type); diff --git a/core/error/error_macros.h b/core/error/error_macros.h index 7f40ca2822..ec5f07dc21 100644 --- a/core/error/error_macros.h +++ b/core/error/error_macros.h @@ -70,6 +70,7 @@ void _err_print_error(const char *p_function, const char *p_file, int p_line, co void _err_print_error(const char *p_function, const char *p_file, int p_line, const String &p_error, const char *p_message, bool p_editor_notify = false, 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, bool p_editor_notify = false, 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, bool p_editor_notify = false, ErrorHandlerType p_type = ERR_HANDLER_ERROR); +void _err_print_error_asap(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, const char *p_message = "", bool p_editor_notify = false, 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 p_editor_notify = false, bool fatal = false); void _err_flush_stdout(); |
