mirror of
https://github.com/godotengine/godot.git
synced 2025-10-26 19:24:18 +00:00
C#: Improve GD.PushError and GD.PushWarning
- Use the name, file path and line number of the caller that invokes `GD.PushError` and `GD.PushWarning` instead of the location in the C++ `runtime_interop.cpp` file. - Improvements to getting the C# stack trace. - Use C# type keywords for built-in types in method declarations. - Remove extra space before each parameter in method declarations. - Skip one more frame to avoid `NativeInterop.NativeFuncs`. - Skip methods annotated with the `[StackTraceHidden]` attribute. - Improvements to `ScriptEditorDebugger` when source is in project. - Avoid overriding error metadata when the source is inside the project file. - Use the source function in the title when the source is inside the project file. Users that use these methods would expect the reported location printed by these methods to correspond to a location in their project source files. Specifically, they'd expect to see the file path and line number at which they call these methods, and not the location of the C++ code (which is always the same). Now, these methods are a lot more useful since users can know which line in their source code printed the error/warning.
This commit is contained in:
parent
83cc5d4914
commit
13ab2b6f4f
7 changed files with 117 additions and 30 deletions
|
|
@ -526,8 +526,11 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da
|
|||
error->set_custom_color(1, color);
|
||||
|
||||
String error_title;
|
||||
if (oe.callstack.size() > 0) {
|
||||
// If available, use the script's stack in the error title.
|
||||
if (!oe.source_func.is_empty() && source_is_project_file) {
|
||||
// If source function is inside the project file.
|
||||
error_title += oe.source_func + ": ";
|
||||
} else if (oe.callstack.size() > 0) {
|
||||
// Otherwise, if available, use the script's stack in the error title.
|
||||
error_title = _format_frame_text(&oe.callstack[0]) + ": ";
|
||||
} else if (!oe.source_func.is_empty()) {
|
||||
// Otherwise try to use the C++ source function.
|
||||
|
|
@ -602,7 +605,10 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da
|
|||
if (i == 0) {
|
||||
stack_trace->set_text(0, "<" + TTR("Stack Trace") + ">");
|
||||
stack_trace->set_text_alignment(0, HORIZONTAL_ALIGNMENT_LEFT);
|
||||
error->set_metadata(0, meta);
|
||||
if (!source_is_project_file) {
|
||||
// Only override metadata if the source is not inside the project.
|
||||
error->set_metadata(0, meta);
|
||||
}
|
||||
tooltip += TTR("Stack Trace:") + "\n";
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue