How can i get the error code after execute ResourceLoader.Load()

Godot Version

v4.3.stable.mono.official [77dcf97d8]

Question

When I use ResourceLoader.Load to load some resources, it might throw errors and print the error messages to the console. how can I catch these errors in my c# codes to handle them properly.

I think you can use this instead, though I’m not sure:

var error = ResourceLoader.load_threaded_request(path)

ResourceLoader.load don’t return an error code, just a resource reference, what you can do is check if the resource was loaded with success doing a null check:

# I will write in gdscript because i'm not familiar with c#, but 
# the logic is equal

func _ready() -> void:
	var my_resource = ResourceLoader.load("path")

	if my_resource:
		print("Loaded without problems")

	else:
		print("Load failed")

This topic was discussed in this thread as well, where OP has opened a proposal on Godot GitHub

You can try use use C# Exceptions and Exception Handling.