Why would Craft produce a template loader error (TemplateLoaderException) when rendering its default error pages? I'm getting a Template Loader Exception when I hit a 404 on my site:

Craft\TemplateLoaderException

Unable to find the template “error”. (/craft/app/etc/templating/twigextensions/TemplateLoader.php:123)

#0 /craft/app/etc/templating/twigextensions/TemplateLoader.php(71): Craft\TemplateLoader-&gt;_findTemplate('error')
#1 /craft/app/vendor/twig/twig/lib/Twig/Environment.php(312): Craft\TemplateLoader-&gt;getCacheKey('error')
#2 /craft/app/vendor/twig/twig/lib/Twig/Environment.php(378): Twig_Environment-&gt;getTemplateClass('error', NULL)
#3 /craft/app/etc/templating/TwigEnvironment.php(23): Twig_Environment-&gt;loadTemplate('error', NULL)
#4 /craft/app/vendor/twig/twig/lib/Twig/Environment.php(347): Craft\TwigEnvironment-&gt;loadTemplate('error')
#5 /craft/app/services/TemplatesService.php(225): Twig_Environment-&gt;render('error', Array)
#6 /craft/app/controllers/BaseController.php(74): Craft\TemplatesService-&gt;render('error', Array)
#7 /craft/app/controllers/TemplatesController.php(201): Craft\BaseController-&gt;renderTemplate('error', Array)
#8 /craft/app/framework/web/actions/CInlineAction.php(49): Craft\TemplatesController-&gt;actionRenderError()
#9 /craft/app/framework/web/CController.php(308): CInlineAction-&gt;runWithParams(Array)
#10 /craft/app/framework/web/CController.php(286): CController-&gt;runAction(Object(CInlineAction))
#11 /craft/app/framework/web/CController.php(265): CController-&gt;runActionWithFilters(Object(CInlineAction), Array)
#12 /craft/app/framework/web/CWebApplication.php(282): CController-&gt;run('renderError')
#13 /craft/app/framework/base/CErrorHandler.php(368): CWebApplication-&gt;runController('templates/rende...')
#14 /craft/app/etc/errors/ErrorHandler.php(281): CErrorHandler-&gt;renderError()
#15 /craft/app/framework/base/CErrorHandler.php(351): Craft\ErrorHandler-&gt;renderError()
#16 /craft/app/framework/base/CErrorHandler.php(218): CErrorHandler-&gt;renderException()
#17 /craft/app/etc/errors/ErrorHandler.php(145): CErrorHandler-&gt;handleException(Object(Craft\HttpException))
#18 /craft/app/framework/base/CErrorHandler.php(131): Craft\ErrorHandler-&gt;handleException(Object(Craft\HttpException))
#19 /craft/app/framework/base/CApplication.php(740): CErrorHandler-&gt;handle(Object(CExceptionEvent))
#20 [internal function]: CApplication-&gt;handleException(Object(Craft\HttpException))
#21 {main}


I haven't added a custom 404 error page, or changed the error template paths in my config, so I would expect Craft to serve up its default error page.

What gives?
As it turns out, I had made a configuration change that broke Craft's default behavior:

'defaultTemplateExtensions' =&gt; array('twig', 'xml')


All of Craft's internal templates use .html, and HTML templates are included in the default value of that config item. By overriding it, I had rendered Craft unable to find its stock error template.

Moral of the story &mdash; When you override defaultTemplateExtensions, make sure to include the default file extensions ('html','twig') in the new list that you set.