1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-04 12:00:25 +00:00

Improve error messages in ResourceLoader

- Remove part of the "Failed loading resource" message about opening
  the project in the editor, as it's sometimes misleading.
- Fix `(expected type: )` appearing at the end of the
  "No loader found for resource:" error message.
This commit is contained in:
Hugo Locurcio
2025-05-22 16:14:27 +02:00
parent 4261cc07a5
commit 16d551a8dd

View File

@@ -339,8 +339,8 @@ Ref<Resource> ResourceLoader::_load(const String &p_path, const String &p_origin
} }
} }
#endif #endif
ERR_FAIL_COND_V_MSG(found, Ref<Resource>(),
vformat("Failed loading resource: %s. Make sure resources have been imported by opening the project in the editor at least once.", p_path)); ERR_FAIL_COND_V_MSG(found, Ref<Resource>(), vformat("Failed loading resource: %s.", p_path));
#ifdef TOOLS_ENABLED #ifdef TOOLS_ENABLED
Ref<FileAccess> file_check = FileAccess::create(FileAccess::ACCESS_RESOURCES); Ref<FileAccess> file_check = FileAccess::create(FileAccess::ACCESS_RESOURCES);
@@ -348,14 +348,14 @@ Ref<Resource> ResourceLoader::_load(const String &p_path, const String &p_origin
if (r_error) { if (r_error) {
*r_error = ERR_FILE_NOT_FOUND; *r_error = ERR_FILE_NOT_FOUND;
} }
ERR_FAIL_V_MSG(Ref<Resource>(), vformat("Resource file not found: %s (expected type: %s)", p_path, p_type_hint)); ERR_FAIL_V_MSG(Ref<Resource>(), vformat("Resource file not found: %s (expected type: %s)", p_path, !p_type_hint.is_empty() ? p_type_hint : "unknown"));
} }
#endif #endif
if (r_error) { if (r_error) {
*r_error = ERR_FILE_UNRECOGNIZED; *r_error = ERR_FILE_UNRECOGNIZED;
} }
ERR_FAIL_V_MSG(Ref<Resource>(), vformat("No loader found for resource: %s (expected type: %s)", p_path, p_type_hint)); ERR_FAIL_V_MSG(Ref<Resource>(), vformat("No loader found for resource: %s (expected type: %s)", p_path, !p_type_hint.is_empty() ? p_type_hint : "unknown"));
} }
// This implementation must allow re-entrancy for a task that started awaiting in a deeper stack frame. // This implementation must allow re-entrancy for a task that started awaiting in a deeper stack frame.