Added try/catch block to template.php.