Development

/branches/1.1/lib/exception/sfError404Exception.class.php

You must first sign up to be able to contribute.

root/branches/1.1/lib/exception/sfError404Exception.class.php

Revision 6975, 1.3 kB (checked in by fabien, 7 years ago)

changed behavior to be sure to have a 404 exception in debug mode and 404 page in production mode (not easy to write tests for this one)

  • Property svn:mime-type set to text/x-php
  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Rev Date
Line 
1 <?php
2
3 /*
4  * This file is part of the symfony package.
5  * (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
6  *
7  * For the full copyright and license information, please view the LICENSE
8  * file that was distributed with this source code.
9  */
10
11 /**
12  * sfError404Exception is thrown when a 404 error occurs in an action.
13  *
14  * @package    symfony
15  * @subpackage exception
16  * @author     Fabien Potencier <fabien.potencier@symfony-project.com>
17  * @version    SVN: $Id$
18  */
19 class sfError404Exception extends sfException
20 {
21   /**
22    * Forwards to the 404 action.
23    */
24   public function printStackTrace()
25   {
26     $exception = is_null($this->wrappedException) ? $this : $this->wrappedException;
27
28     if (sfConfig::get('sf_debug'))
29     {
30       $response = sfContext::getInstance()->getResponse();
31       if (is_null($response))
32       {
33         $response = new sfWebResponse(sfContext::getInstance()->getEventDispatcher());
34         sfContext::getInstance()->setResponse($response);
35       }
36
37       $response->setStatusCode(404);
38
39       return parent::printStackTrace();
40     }
41     else
42     {
43       // log all exceptions in php log
44       if (!sfConfig::get('sf_test'))
45       {
46         error_log($this->getMessage());
47       }
48
49       sfContext::getInstance()->getController()->forward(sfConfig::get('sf_error_404_module'), sfConfig::get('sf_error_404_action'));
50     }
51   }
52 }
53
Note: See TracBrowser for help on using the browser.