[functions] give nicer and a bit more meaningful error messages