<p>As it turns out, I <em>had</em> made a configuration change that broke Craft's default behavior:</p>

<pre><code>'defaultTemplateExtensions' =&gt; array('twig', 'xml')
</code></pre>

<p>All of Craft's internal templates use <code>.html</code>, 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.</p>

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

CC BY-SA 3.0
2015-11-24T22:52:20.363Z
2015-11-24T22:52:20.363Z
Michael Rog
<p>I'm getting a Template Loader Exception when I hit a 404 on my site:</p>

<pre><code>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}
</code></pre>

<p>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.</p>

<p>What gives?</p>

<config><error-message><error><error-templates><configuration>
Why would Craft produce a template loader error (TemplateLoaderException) when rendering its default error pages?
# Why would Craft produce a template loader error (TemplateLoaderException) when rendering its default error pages?

(Asked by: username_0 on 2015-11-24)

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

**Tags:** config, error-message, error, error-templates, configuration


---

## 1 answers

### Answer by username_0 on 2015-11-24. Score: 3 | Accepted answer

As it turns out, I had made a configuration change that broke Craft's default behavior:
'defaultTemplateExtensions' => 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 — When you override defaultTemplateExtensions, make sure to include the default file extensions ('html','twig') in the new list that you set.


---

