Improve error messages for method calls expecting only 1 argument

This commit is contained in:
Rémi Verschelde
2025-06-12 17:02:59 +02:00
parent 03bd8ba9c2
commit d1083c9722
7 changed files with 8 additions and 8 deletions

View File

@ -180,7 +180,7 @@ namespace Godot
/// static void Trampoline(object delegateObj, NativeVariantPtrArgs args, out godot_variant ret)
/// {
/// if (args.Count != 1)
/// throw new ArgumentException($"Callable expected {1} arguments but received {args.Count}.");
/// throw new ArgumentException($"Callable expected {1} argument but received {args.Count}.");
///
/// TResult res = ((Func<int, string>)delegateObj)(
/// VariantConversionCallbacks.GetToManagedCallback<int>()(args[0])

View File

@ -19,7 +19,7 @@ public readonly partial struct Callable
{
throw new ArgumentException(
"Invalid argument count for invoking callable." +
$" Expected {countExpected} arguments, received {countReceived}.",
$" Expected {countExpected} argument(s), received {countReceived}.",
paramName);
}
}

View File

@ -211,7 +211,7 @@ namespace Godot.NativeInterop
}
case godot_variant_call_error_error.GODOT_CALL_ERROR_CALL_ERROR_TOO_MANY_ARGUMENTS:
case godot_variant_call_error_error.GODOT_CALL_ERROR_CALL_ERROR_TOO_FEW_ARGUMENTS:
return $"Invalid call to {where}. Expected {error.Expected} arguments.";
return $"Invalid call to {where}. Expected {error.Expected} argument(s).";
case godot_variant_call_error_error.GODOT_CALL_ERROR_CALL_ERROR_INVALID_METHOD:
return $"Invalid call. Nonexistent {where}.";
case godot_variant_call_error_error.GODOT_CALL_ERROR_CALL_ERROR_INSTANCE_IS_NULL: