1

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?

3

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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.