Error function in template