Skip to content

Commit a6c7ee8

Browse files
Validate file exists for add_translation_from_resource (#118)
* `add_translation_from_resource` - Validate file exists * `add_translation_from_resource` - fix log name in previous commit
1 parent a3ff6c4 commit a6c7ee8

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

addons/mod_loader/mod_loader.gd

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,10 @@ func register_global_classes_from_array(new_global_classes: Array) -> void:
510510
# file should have been created in Godot already: When you improt a CSV, such
511511
# a file will be created for you.
512512
func add_translation_from_resource(resource_path: String) -> void:
513+
if not File.new().file_exists(resource_path):
514+
ModLoaderUtils.log_fatal("Tried to load a translation resource from a file that doesn't exist. The invalid path was: %s" % [resource_path], LOG_NAME)
515+
return
516+
513517
var translation_object: Translation = load(resource_path)
514518
TranslationServer.add_translation(translation_object)
515519
ModLoaderUtils.log_info("Added Translation from Resource -> %s" % resource_path, LOG_NAME)

0 commit comments

Comments
 (0)