Browse Source

Merge pull request #86653 from Mickeon/string-format-error

Improve error message for `String.format` when using nested Arrays
Thaddeus Crews 4 months ago
parent
commit
60aae6d856
1 changed files with 1 additions and 1 deletions
  1. 1 1
      core/string/ustring.cpp

+ 1 - 1
core/string/ustring.cpp

@@ -3863,7 +3863,7 @@ String String::format(const Variant &values, const String &placeholder) const {
 
 
 					new_string = new_string.replace(placeholder.replace("_", key), val);
 					new_string = new_string.replace(placeholder.replace("_", key), val);
 				} else {
 				} else {
-					ERR_PRINT(String("STRING.format Inner Array size != 2 ").ascii().get_data());
+					ERR_PRINT(vformat("Invalid format: the inner Array at index %d needs to contain only 2 elements, as a key-value pair.", i).ascii().get_data());
 				}
 				}
 			} else { //Array structure ["RobotGuy","Logis","rookie"]
 			} else { //Array structure ["RobotGuy","Logis","rookie"]
 				Variant v_val = values_arr[i];
 				Variant v_val = values_arr[i];