summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2022-06-30 19:06:06 +0200
committerGitHub <noreply@github.com>2022-06-30 19:06:06 +0200
commit8c8eea9428d094c3f2cc6731e3e2cbd84a5a316b (patch)
treed85d09197bcd3b00937fda25758064780c6589b1 /core
parent55048b1ca5a524e839d6ad20f8b1ec758c829768 (diff)
parentc83084fccb4cdc42d2ca324c974ace0cf974630d (diff)
Merge pull request #62555 from akien-mga/error-fallback-to-fprintf
Diffstat (limited to 'core')
-rw-r--r--core/error/error_macros.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/core/error/error_macros.cpp b/core/error/error_macros.cpp
index 8add4b9a3a..f71a642b23 100644
--- a/core/error/error_macros.cpp
+++ b/core/error/error_macros.cpp
@@ -83,7 +83,13 @@ void _err_print_error(const char *p_function, const char *p_file, int p_line, co
// Main error printing function.
void _err_print_error(const char *p_function, const char *p_file, int p_line, const char *p_error, const char *p_message, bool p_editor_notify, ErrorHandlerType p_type) {
- OS::get_singleton()->print_error(p_function, p_file, p_line, p_error, p_message, p_editor_notify, (Logger::ErrorType)p_type);
+ if (OS::get_singleton()) {
+ OS::get_singleton()->print_error(p_function, p_file, p_line, p_error, p_message, p_editor_notify, (Logger::ErrorType)p_type);
+ } else {
+ // Fallback if errors happen before OS init or after it's destroyed.
+ const char *err_details = (p_message && *p_message) ? p_message : p_error;
+ fprintf(stderr, "ERROR: %s\n at: %s (%s:%i)\n", err_details, p_function, p_file, p_line);
+ }
_global_lock();
ErrorHandlerList *l = error_handler_list;