Skip to content

Commit d9df169

Browse files
committed
Display toasts when using push_error() or push_warning() in a script
This only applies to scripts running within the editor itself, such as editor plugins and `@tool` scripts. Text-based logging will also display those errors as userspace errors, as opposed to internal engine errors.
1 parent e7d2e49 commit d9df169

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

core/variant/variant_utility.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -902,7 +902,8 @@ struct VariantUtilityFunctions {
902902
}
903903
}
904904

905-
ERR_PRINT(s);
905+
// Display a toast for editor plugins or `@tool` scripts.
906+
ERR_PRINT_ED(s);
906907
r_error.error = Callable::CallError::CALL_OK;
907908
}
908909

@@ -922,7 +923,8 @@ struct VariantUtilityFunctions {
922923
}
923924
}
924925

925-
WARN_PRINT(s);
926+
// Display a toast for editor plugins or `@tool` scripts.
927+
WARN_PRINT_ED(s);
926928
r_error.error = Callable::CallError::CALL_OK;
927929
}
928930

doc/classes/@GlobalScope.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -908,7 +908,7 @@
908908
</method>
909909
<method name="push_error" qualifiers="vararg">
910910
<description>
911-
Pushes an error message to Godot's built-in debugger and to the OS terminal.
911+
Pushes an error message to Godot's built-in debugger and to the OS terminal. When used in an [EditorPlugin] or [code]@tool[/code] script, this also displays an error toast in the editor.
912912
[codeblocks]
913913
[gdscript]
914914
push_error("test error") # Prints "test error" to debugger and terminal as error call
@@ -922,7 +922,7 @@
922922
</method>
923923
<method name="push_warning" qualifiers="vararg">
924924
<description>
925-
Pushes a warning message to Godot's built-in debugger and to the OS terminal.
925+
Pushes a warning message to Godot's built-in debugger and to the OS terminal. When used in an [EditorPlugin] or [code]@tool[/code] script, this also displays a warning toast in the editor.
926926
[codeblocks]
927927
[gdscript]
928928
push_warning("test warning") # Prints "test warning" to debugger and terminal as warning call

0 commit comments

Comments
 (0)