a better error message when code is invalid