Skip to content

Add GDExtension print_script_error and print_script_error_with_message - #121199

Closed
Naros wants to merge 1 commit into
godotengine:masterfrom
Naros:add-err_print_script_error-gde
Closed

Add GDExtension print_script_error and print_script_error_with_message#121199
Naros wants to merge 1 commit into
godotengine:masterfrom
Naros:add-err_print_script_error-gde

Conversation

@Naros

@Naros Naros commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

What problem(s) does this PR solve?

This adds the GDExtension JSON mapping for print_script_error and print_script_error_with_message bindings that we are planning to add on godot-cpp side.

Additional information

This is from a RChat discussion we had about the fact there is no way for scripting extensions written in GDExtension to use ERR_HANDLER_SCRIPT to report script-specific errors like GDScript does. This exposes the already present methods in gdextension_interface.cpp to the godot-cpp bindings.

This is needed for godotengine/godot-cpp#2022

@Naros
Naros requested a review from a team as a code owner July 10, 2026 21:56
@Nintorch Nintorch added this to the 4.x milestone Jul 12, 2026

@dsnopek dsnopek left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

The changes to the gdextension_interface.json look good, and match print_error and print_warning. However, this is missing the actual implementation in gdextension_interface.cpp

@Bromeon Bromeon left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The functions already exist on master. This PR duplicates them -- so it shouldn't be needed.

CI was skipped, would it catch duplicates?

Comment on lines +3977 to +4071
{
"name": "print_script_error",
"arguments": [
{
"name": "p_description",
"type": "const char*",
"description": [
"The code triggering the error."
]
},
{
"name": "p_function",
"type": "const char*",
"description": [
"The function name where the error occurred."
]
},
{
"name": "p_file",
"type": "const char*",
"description": [
"The file where the error occurred."
]
},
{
"name": "p_line",
"type": "int32_t",
"description": [
"The line where the error occurred."
]
},
{
"name": "p_editor_notify",
"type": "GDExtensionBool",
"description": [
"Whether or not to notify the editor."
]
}
],
"description": [
"Logs a script error to Godot's built-in debugger and to the OS terminal."
],
"since": "4.8"
},
{
"name": "print_script_error_with_message",
"arguments": [
{
"name": "p_description",
"type": "const char*",
"description": [
"The code triggering the error."
]
},
{
"name": "p_message",
"type": "const char*",
"description": [
"The message to show along with the error."
]
},
{
"name": "p_function",
"type": "const char*",
"description": [
"The function name where the error occurred."
]
},
{
"name": "p_file",
"type": "const char*",
"description": [
"The file where the error occurred."
]
},
{
"name": "p_line",
"type": "int32_t",
"description": [
"The line where the error occurred."
]
},
{
"name": "p_editor_notify",
"type": "GDExtensionBool",
"description": [
"Whether or not to notify the editor."
]
}
],
"description": [
"Logs a script error with a message to Godot's built-in debugger and to the OS terminal."
],
"since": "4.8"
},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are already on master, at (now) position 14 and 15.
The ones added in this PR are at position 10 and 11 in the same array.

{
"name": "print_script_error",
"arguments": [
{
"name": "p_description",
"type": "const char*",
"description": [
"The code triggering the error."
]
},
{
"name": "p_function",
"type": "const char*",
"description": [
"The function name where the error occurred."
]
},
{
"name": "p_file",
"type": "const char*",
"description": [
"The file where the error occurred."
]
},
{
"name": "p_line",
"type": "int32_t",
"description": [
"The line where the error occurred."
]
},
{
"name": "p_editor_notify",
"type": "GDExtensionBool",
"description": [
"Whether or not to notify the editor."
]
}
],
"description": [
"Logs a script error to Godot's built-in debugger and to the OS terminal."
],
"since": "4.1"
},
{
"name": "print_script_error_with_message",
"arguments": [
{
"name": "p_description",
"type": "const char*",
"description": [
"The code triggering the error."
]
},
{
"name": "p_message",
"type": "const char*",
"description": [
"The message to show along with the error."
]
},
{
"name": "p_function",
"type": "const char*",
"description": [
"The function name where the error occurred."
]
},
{
"name": "p_file",
"type": "const char*",
"description": [
"The file where the error occurred."
]
},
{
"name": "p_line",
"type": "int32_t",
"description": [
"The line where the error occurred."
]
},
{
"name": "p_editor_notify",
"type": "GDExtensionBool",
"description": [
"Whether or not to notify the editor."
]
}
],
"description": [
"Logs a script error with a message to Godot's built-in debugger and to the OS terminal."
],
"since": "4.1"
},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! I didn't recall having these methods

I don't know if CI would have caught it. The JSON parser may have just had the second one overwrite the first?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, we don't see this because of the CI-skipped issue 🤡
I attempted to fix the skip in #121734.

The original duplication might cause a compile error, but different C/C++ compiler versions may be lenient to identical typedefs. To be on the safe side (also in presence of toolchain changes) I also opened #121733.

@Bromeon

Bromeon commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

So this can be closed, no?

@dsnopek

dsnopek commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Yes, I think so

@dsnopek dsnopek closed this Jul 29, 2026
@AThousandShips AThousandShips removed this from the 4.x milestone Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants