http status code 404 - Symfony's createNotFoundException not returning 404 page -


i have symfony action trying return 404 error when query returns null.

i regular page's template returned , 200 http return code.

i have checked , error logs show createnotfoundexception firing.

i running symfony 2.7.1

any ideas why code not returning 404 page?

<?php  namespace example\groupbundle\controller;  use symfony\bundle\frameworkbundle\controller\controller; use sensio\bundle\frameworkextrabundle\configuration\route; use sensio\bundle\frameworkextrabundle\configuration\template; use sensio\bundle\frameworkextrabundle\configuration\method; use symfony\component\httpfoundation\request;  use example\groupbundle\entity\group;  /**  * class supportgrouplandingcontroller  * @package example\groupbundle\controller  *  * @route("/group")  */ class supportgroupcontroller extends controller {     /**      * @route("/{name}", name="support_group_page")      * @method("get")      * @template("examplegroupbundle::group_page.html.twig")      *      * @param $name      * @return array      */     public function indexaction($name)     {         $repo = $this->getdoctrine()->getrepository('examplegroupbundle:group');         $group = $repo->findoneby(array('name' => $name));          if ($group === null) {             error_log('group null');              return $this->createnotfoundexception('support group not exist');              error_log('this should not here');          } else {             error_log('group not null: '.var_export($group, true));         }          return array('group' => $group);     }   } 

symfony debug toolbar

you need not return $this->createnotfoundexception('support group not exist'); throw it:

throw $this->createnotfoundexception('support group not exist'); 

Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -