| 1 |
lars |
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: sfError404Exception.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
|
|
|
18 |
*/
|
|
|
19 |
class sfError404Exception extends sfException
|
|
|
20 |
{
|
|
|
21 |
/**
|
|
|
22 |
* Forwards to the 404 action.
|
|
|
23 |
*/
|
|
|
24 |
public function printStackTrace()
|
|
|
25 |
{
|
|
|
26 |
$exception = null === $this->wrappedException ? $this : $this->wrappedException;
|
|
|
27 |
|
|
|
28 |
if (sfConfig::get('sf_debug'))
|
|
|
29 |
{
|
|
|
30 |
$response = sfContext::getInstance()->getResponse();
|
|
|
31 |
if (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 |
}
|