Inject function for error treatment; parse template files