Skip to content

Commit a06b0a0

Browse files
authored
Merge pull request #876 from Spartan322/revert/a0c1744
[4.3] Revert "ResourceLoader: Report error if resource type unrecognized"
2 parents 9ba2401 + e6c4359 commit a06b0a0

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
@@ -286,13 +286,13 @@ Ref<Resource> ResourceLoader::_load(const String &p_path, const String &p_origin
286286
load_paths_stack.push_back(original_path);
287287

288288
// Try all loaders and pick the first match for the type hint
289-
bool loader_found = false;
289+
bool found = false;
290290
Ref<Resource> res;
291291
for (int i = 0; i < loader_count; i++) {
292292
if (!loader[i]->recognize_path(p_path, p_type_hint)) {
293293
continue;
294294
}
295-
loader_found = true;
295+
found = true;
296296
res = loader[i]->load(p_path, original_path, r_error, p_use_sub_threads, r_progress, p_cache_mode);
297297
if (!res.is_null()) {
298298
break;
@@ -307,24 +307,15 @@ Ref<Resource> ResourceLoader::_load(const String &p_path, const String &p_origin
307307
return res;
308308
}
309309

310-
if (!loader_found) {
311-
if (r_error) {
312-
*r_error = ERR_FILE_UNRECOGNIZED;
313-
}
314-
ERR_FAIL_V_MSG(Ref<Resource>(), vformat("No loader found for resource: %s (expected type: %s)", p_path, p_type_hint));
315-
}
310+
ERR_FAIL_COND_V_MSG(found, Ref<Resource>(),
311+
vformat("Failed loading resource: %s. Make sure resources have been imported by opening the project in the editor at least once.", p_path));
316312

317313
#ifdef TOOLS_ENABLED
318314
Ref<FileAccess> file_check = FileAccess::create(FileAccess::ACCESS_RESOURCES);
319-
if (!file_check->file_exists(p_path)) {
320-
if (r_error) {
321-
*r_error = ERR_FILE_NOT_FOUND;
322-
}
323-
ERR_FAIL_V_MSG(Ref<Resource>(), vformat("Resource file not found: %s (expected type: %s)", p_path, p_type_hint));
324-
}
315+
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));
325316
#endif
326317

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

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

0 commit comments

Comments
 (0)