Requests for non-existent templates/pages (404s) result in an uncaught HttpException.404 being thrown, though the correct 404 template is displayed. Is there some way to suppress or handle this exception? It's flooding my error reporting tool. For reference, here's the stack trace from the log:

2016/12/07 17:29:07 [error] [exception.Craft\HttpException.404] exception 'Craft\HttpException' in /project/craft/app/controllers/TemplatesController.php:59
Stack trace:
#0 [internal function]: Craft\TemplatesController->actionRender('page-no-existy', Array)
#1 /project/craft/app/framework/web/actions/CAction.php(109): ReflectionMethod->invokeArgs(Object(Craft\TemplatesController), Array)
#2 /project/craft/app/framework/web/actions/CInlineAction.php(47): CAction->runWithParamsInternal(Object(Craft\TemplatesController), Object(ReflectionMethod), Array)
#3 /project/craft/app/framework/web/CController.php(308): CInlineAction->runWithParams(Array)
#4 /project/craft/app/framework/web/CController.php(286): CController->runAction(Object(CInlineAction))
#5 /project/craft/app/framework/web/CController.php(265): CController->runActionWithFilters(Object(CInlineAction), Array)
#6 /project/craft/app/framework/web/CWebApplication.php(282): CController->run('render')
#7 /project/craft/app/framework/web/CWebApplication.php(141): CWebApplication->runController('templates/rende...')
#8 /project/craft/app/etc/web/WebApp.php(290): CWebApplication->processRequest()
#9 /project/craft/app/framework/base/CApplication.php(185): Craft\WebApp->processRequest()
#10 /project/craft/app/index.php(62): CApplication->run()
#11 /project/src/static/index.php(21): require_once('/project...')
#12 {main}
  • As a workaround, I just told New Relic to ignore these exceptions. In the appropriate newrelic.ini for your version of PHP, add newrelic.error_collector.ignore_exceptions = "Craft\HttpException"
    – Garrett
    Dec 8, 2016 at 17:47
  • This is driving us crazy as well. By adding this exception, it seems like you would lose reporting on any HttpException though, can you confirm @garrett?
    – tekstrand
    Oct 16, 2017 at 14:14
  • 1
    @TheEks yes, any exception that is an instance of Craft\HttpException. I've since stopped using New Relic, so I can't comment on whether this is still a good idea (if it ever was!).
    – Garrett
    Oct 17, 2017 at 22:50

1 Answer 1


The good news in the upcoming Craft 3 this isn't an issue. 404's get logged to their own separate log files and won't clutter up the main Craft log files specifically for this reason.

In Craft 2, I think you'd have to do something like write a plugin that listens for Yii's onException event, makes sure it's a 404 status code, then go through Yii's CLogger to get the full list of log entries and remove the last one.

  • Will they still throw an uncaught exception? My main issue is that the 404 exceptions show up in New Relic.
    – Garrett
    Dec 8, 2016 at 17:43
  • It should! You'd just be listening for all exceptions, checking if the current one is a 404, then if so, modify the logging information. The request of the exception request would continue as usual.
    – Brad Bell
    Dec 8, 2016 at 17:49

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.