godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.06k stars 65 forks source link

Include specific error in Stack Trace when warnings as error is enabled #9147

Open regner opened 3 months ago

regner commented 3 months ago

Describe the project you are working on

Twin stick local multiplayer game

Describe the problem or limitation you are having in your project

I and the developers I am working with prefer to run with warnings as error as early in our project as possible. As some of us are new to Godot and GDScript we have found knowing the proper error name is important when searching the internet for solutions. With warnings as error enabled however we only get the string description of the error, not the error itself.

Specific example: I was getting an error for UNSAFE_METHOD_ACCESS when running our project. When this error is hit the Godot editor displays Parser Error: The method "transition_to_ready_room()" is not present on the inferred type "Node" (but may be present on a subtype). (Warning treated as error.)

image

If we run with unsafe_method_access=1 as instead we are given slightly more information. Importantly we learn that this is a UNSAFE_METHOD_ACCESS error.

image

Searching Kagi for godot gdscript UNSAFE_METHOD_ACCESS gives me the answer I needed as a first result. Searching with godot gdscript The method is not present on the inferred type "Node" does not give me the correct response immedietly.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

I think it would be great if the actual error name itself was included in some way in the messaging to developers.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

Add the error name in the string, possible as Parser Error: UNSAFE_METHOD_ACCESS: ....

If this enhancement will not be used often, can it be worked around with a few lines of script?

Not that I am aware of, and it would be used often.

Is there a reason why this should be core and not an add-on in the asset library?

Admitidly I am new to Godot, but I don't think an add-on could change this behaviour.

otonashixav commented 2 weeks ago

This is especially needed for the editor itself, where you don't get a stack trace and can't get the name of the warning to @warning_ignore it: image

Leaving you to guess or open the list of warnings to figure it out.