1
0
mirror of https://github.com/MontFerret/ferret.git synced 2026-06-20 01:17:53 +02:00

feat: add ArgTypeError function for improved argument type validation

This commit is contained in:
Tim Voronov
2026-04-24 13:58:49 -04:00
parent 29b2d956a0
commit d7c4fc0d02
+6
View File
@@ -8,6 +8,12 @@ func ArgError(err error, pos int) error {
return newInvalidArgumentError(err, pos)
}
// ArgTypeError returns an error indicating that the argument at the specified position does not match the expected type.
// The position is 0-based internally but reported as 1-based to users.
func ArgTypeError(arg Value, pos int, expected ...Type) error {
return ArgError(TypeErrorOf(arg, expected...), pos)
}
// ArityError returns an error if the number of arguments is outside the [minimum, maximum] range.
// The minimum and maximum values are inclusive.
func ArityError(count, minimum, maximum int) error {