summaryrefslogtreecommitdiffstats
path: root/core/error/error_macros.cpp
diff options
context:
space:
mode:
authorGeorge L. Albany <Megacake1234@gmail.com>2024-10-27 13:25:03 +0000
committerGitHub <noreply@github.com>2024-10-27 13:25:03 +0000
commit6e3e9dfb9857b751f59fd4b40c55e9262ff5a864 (patch)
treed064b49a4766ab69a0ac6e195868ad4b3443bab3 /core/error/error_macros.cpp
parentbec9ffacba1385b0ba808f6dbb66abb7dc53639d (diff)
parent953af98c795066a5a450a3401cc8a4fbc6c12620 (diff)
downloadredot-engine-6e3e9dfb9857b751f59fd4b40c55e9262ff5a864.tar.gz
Merge pull request #814 from Spartan322/merge/61accf0
Merge commit godotengine/godot@61accf0
Diffstat (limited to 'core/error/error_macros.cpp')
-rw-r--r--core/error/error_macros.cpp22
1 files changed, 22 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);