Skip to content

Commit 6eb6e3e

Browse files
committed
Merge pull request #107457 from akien-mga/improve-error-message-call-single-argument
Improve error messages for method calls expecting only 1 argument
2 parents a4b9978 + d1083c9 commit 6eb6e3e

File tree

7 files changed

+8
-8
lines changed

7 files changed

+8
-8
lines changed

core/math/expression.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ Expression::ENode *Expression::_parse_expression() {
823823
if (!Variant::is_utility_function_vararg(bifunc->func)) {
824824
int expected_args = Variant::get_utility_function_argument_count(bifunc->func);
825825
if (expected_args != bifunc->arguments.size()) {
826-
_set_error("Builtin func '" + String(bifunc->func) + "' expects " + itos(expected_args) + " arguments.");
826+
_set_error("Builtin func '" + String(bifunc->func) + "' expects " + itos(expected_args) + " argument(s).");
827827
}
828828
}
829829

core/variant/variant.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3501,9 +3501,9 @@ String Variant::get_call_error_text(Object *p_base, const StringName &p_method,
35013501
err_text = "Cannot convert argument " + itos(errorarg + 1) + " from [missing argptr, type unknown] to " + Variant::get_type_name(Variant::Type(ce.expected));
35023502
}
35033503
} else if (ce.error == Callable::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS) {
3504-
err_text = "Method expected " + itos(ce.expected) + " arguments, but called with " + itos(p_argcount);
3504+
err_text = "Method expected " + itos(ce.expected) + " argument(s), but called with " + itos(p_argcount);
35053505
} else if (ce.error == Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS) {
3506-
err_text = "Method expected " + itos(ce.expected) + " arguments, but called with " + itos(p_argcount);
3506+
err_text = "Method expected " + itos(ce.expected) + " argument(s), but called with " + itos(p_argcount);
35073507
} else if (ce.error == Callable::CallError::CALL_ERROR_INVALID_METHOD) {
35083508
err_text = "Method not found";
35093509
} else if (ce.error == Callable::CallError::CALL_ERROR_INSTANCE_IS_NULL) {

modules/gdscript/gdscript_vm.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ String GDScriptFunction::_get_call_error(const String &p_where, const Variant **
177177
return "Invalid type in " + p_where + ". Cannot convert argument " + itos(p_err.argument + 1) + " from " + Variant::get_type_name(p_argptrs[p_err.argument]->get_type()) + " to " + Variant::get_type_name(Variant::Type(p_err.expected)) + ".";
178178
case Callable::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS:
179179
case Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS:
180-
return "Invalid call to " + p_where + ". Expected " + itos(p_err.expected) + " arguments.";
180+
return "Invalid call to " + p_where + ". Expected " + itos(p_err.expected) + " argument(s).";
181181
case Callable::CallError::CALL_ERROR_INSTANCE_IS_NULL:
182182
return "Attempt to call " + p_where + " on a null instance.";
183183
case Callable::CallError::CALL_ERROR_METHOD_NOT_CONST:

modules/mono/glue/GodotSharp/GodotSharp/Core/Callable.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ public unsafe void CallDeferred(params Variant[] args)
180180
/// static void Trampoline(object delegateObj, NativeVariantPtrArgs args, out godot_variant ret)
181181
/// {
182182
/// if (args.Count != 1)
183-
/// throw new ArgumentException($"Callable expected {1} arguments but received {args.Count}.");
183+
/// throw new ArgumentException($"Callable expected {1} argument but received {args.Count}.");
184184
///
185185
/// TResult res = ((Func<int, string>)delegateObj)(
186186
/// VariantConversionCallbacks.GetToManagedCallback<int>()(args[0])

modules/mono/glue/GodotSharp/GodotSharp/Core/Callable.generics.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ static void ThrowArgCountMismatch(int countExpected, int countReceived, string?
1919
{
2020
throw new ArgumentException(
2121
"Invalid argument count for invoking callable." +
22-
$" Expected {countExpected} arguments, received {countReceived}.",
22+
$" Expected {countExpected} argument(s), received {countReceived}.",
2323
paramName);
2424
}
2525
}

modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/ExceptionUtils.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ private unsafe static string GetCallErrorMessage(godot_variant_call_error error,
211211
}
212212
case godot_variant_call_error_error.GODOT_CALL_ERROR_CALL_ERROR_TOO_MANY_ARGUMENTS:
213213
case godot_variant_call_error_error.GODOT_CALL_ERROR_CALL_ERROR_TOO_FEW_ARGUMENTS:
214-
return $"Invalid call to {where}. Expected {error.Expected} arguments.";
214+
return $"Invalid call to {where}. Expected {error.Expected} argument(s).";
215215
case godot_variant_call_error_error.GODOT_CALL_ERROR_CALL_ERROR_INVALID_METHOD:
216216
return $"Invalid call. Nonexistent {where}.";
217217
case godot_variant_call_error_error.GODOT_CALL_ERROR_CALL_ERROR_INSTANCE_IS_NULL:

servers/rendering/shader_language.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3578,7 +3578,7 @@ bool ShaderLanguage::_validate_function_call(BlockNode *p_block, const FunctionI
35783578
// Stage-based function.
35793579
const StageFunctionInfo &sf = E.value.stage_functions[name];
35803580
if (argcount != sf.arguments.size()) {
3581-
_set_error(vformat(RTR("Invalid number of arguments when calling stage function '%s', which expects %d arguments."), String(name), sf.arguments.size()));
3581+
_set_error(vformat(RTR("Invalid number of arguments when calling stage function '%s', which expects %d argument(s)."), String(name), sf.arguments.size()));
35823582
return false;
35833583
}
35843584
// Validate arguments.

0 commit comments

Comments
 (0)