throw error if template is undefined