Skip to content

Commit 9e60984

Browse files
committed
Merge pull request #99469 from akien-mga/revert-97370
Revert "ResourceLoader: Report error if resource type unrecognized"
2 parents cfef794 + 219b14b commit 9e60984

File tree

1 file changed

+6
-15
lines changed

1 file changed

+6
-15
lines changed

core/io/resource_loader.cpp

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -295,13 +295,13 @@ Ref<Resource> ResourceLoader::_load(const String &p_path, const String &p_origin
295295
load_paths_stack.push_back(original_path);
296296

297297
// Try all loaders and pick the first match for the type hint
298-
bool loader_found = false;
298+
bool found = false;
299299
Ref<Resource> res;
300300
for (int i = 0; i < loader_count; i++) {
301301
if (!loader[i]->recognize_path(p_path, p_type_hint)) {
302302
continue;
303303
}
304-
loader_found = true;
304+
found = true;
305305
res = loader[i]->load(p_path, original_path, r_error, p_use_sub_threads, r_progress, p_cache_mode);
306306
if (!res.is_null()) {
307307
break;
@@ -316,24 +316,15 @@ Ref<Resource> ResourceLoader::_load(const String &p_path, const String &p_origin
316316
return res;
317317
}
318318

319-
if (!loader_found) {
320-
if (r_error) {
321-
*r_error = ERR_FILE_UNRECOGNIZED;
322-
}
323-
ERR_FAIL_V_MSG(Ref<Resource>(), vformat("No loader found for resource: %s (expected type: %s)", p_path, p_type_hint));
324-
}
319+
ERR_FAIL_COND_V_MSG(found, Ref<Resource>(),
320+
vformat("Failed loading resource: %s. Make sure resources have been imported by opening the project in the editor at least once.", p_path));
325321

326322
#ifdef TOOLS_ENABLED
327323
Ref<FileAccess> file_check = FileAccess::create(FileAccess::ACCESS_RESOURCES);
328-
if (!file_check->file_exists(p_path)) {
329-
if (r_error) {
330-
*r_error = ERR_FILE_NOT_FOUND;
331-
}
332-
ERR_FAIL_V_MSG(Ref<Resource>(), vformat("Resource file not found: %s (expected type: %s)", p_path, p_type_hint));
333-
}
324+
ERR_FAIL_COND_V_MSG(!file_check->file_exists(p_path), Ref<Resource>(), vformat("Resource file not found: %s (expected type: %s)", p_path, p_type_hint));
334325
#endif
335326

336-
ERR_FAIL_V_MSG(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));
327+
ERR_FAIL_V_MSG(Ref<Resource>(), vformat("No loader found for resource: %s (expected type: %s)", p_path, p_type_hint));
337328
}
338329

339330
// This implementation must allow re-entrancy for a task that started awaiting in a deeper stack frame.

0 commit comments

Comments
 (0)