Throw an error if invalid arguments are given.