throw error if argument is invalid