AppSync footgun: util.error does not work if called with non-string arguments

The util.error
function terminates the current resolver with the error provided in the argument, similar to how an exception would work. Its signature is:
util.error(String, String?, Object?, Object?)
But what happens when the provided arguments don't match this signature?
Consider this code:
if (ctx.result.statusCode < 200 || ctx.result.statusCode >= 300) {
util.error(ctx.result.statusCode);
}
return JSON.parse(ctx.result.body);
The expectation here is that if the statusCode
is outside the 2xx range then it will result in an error.
But what happens instead is that the util.error
is silently ignored. There is no error, no warning, it behaves as it was never called.
All these lines are no-ops:
util.error(25);
util.error(true);
util.error("abc", 25);
Issue opened at https://github.com/aws/aws-appsync-community/issues/384.