better error handling in template extraction