Skip to content

Commit c54fa98

Browse files
committed
Extra configurable exceptions for 403, 401, 40x
1 parent ff7cffd commit c54fa98

File tree

3 files changed

+132
-0
lines changed

3 files changed

+132
-0
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the symfony package.
5+
* (c) 2004-2006 Fabien Potencier <[email protected]>
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 <[email protected]>
17+
* @version SVN: $Id: sfError404Exception.class.php 3243 2007-01-12 14:22:50Z fabien $
18+
*/
19+
class sfError401Exception extends sfException
20+
{
21+
/**
22+
* Class constructor.
23+
*
24+
* @param string The error message
25+
* @param int The error code
26+
*/
27+
public function __construct($message = null, $code = 0)
28+
{
29+
$this->setName('sfError401Exception');
30+
parent::__construct($message, $code);
31+
}
32+
33+
/**
34+
* Forwards to the 401 action.
35+
*
36+
* @param Exception An Exception implementation instance
37+
*/
38+
public function printStackTrace($exception = null)
39+
{
40+
$sfContext = sfContext::getInstance();
41+
$sfContext->getRequest()->setParameter('message', $this->getMessage());
42+
$sfContext->getController()->forward(sfConfig::get('sf_error_401_module'), sfConfig::get('sf_error_401_action'));
43+
}
44+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the symfony package.
5+
* (c) 2004-2006 Fabien Potencier <[email protected]>
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 <[email protected]>
17+
* @version SVN: $Id: sfError404Exception.class.php 3243 2007-01-12 14:22:50Z fabien $
18+
*/
19+
class sfError403Exception extends sfException
20+
{
21+
/**
22+
* Class constructor.
23+
*
24+
* @param string The error message
25+
* @param int The error code
26+
*/
27+
public function __construct($message = null, $code = 0)
28+
{
29+
$this->setName('sfError403Exception');
30+
parent::__construct($message, $code);
31+
}
32+
33+
/**
34+
* Forwards to the 403 action.
35+
*
36+
* @param Exception An Exception implementation instance
37+
*/
38+
public function printStackTrace($exception = null)
39+
{
40+
$sfContext = sfContext::getInstance();
41+
$sfContext->getRequest()->setParameter('message', $this->getMessage());
42+
$sfContext->getController()->forward(sfConfig::get('sf_error_403_module'), sfConfig::get('sf_error_403_action'));
43+
}
44+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the symfony package.
5+
* (c) 2004-2006 Fabien Potencier <[email protected]>
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 <[email protected]>
17+
* @version SVN: $Id: sfError404Exception.class.php 3243 2007-01-12 14:22:50Z fabien $
18+
*/
19+
class sfError40xException extends sfException
20+
{
21+
/**
22+
* Class constructor.
23+
*
24+
* @param string The error message
25+
* @param int The error code
26+
*/
27+
public function __construct($message = null, $code = 0)
28+
{
29+
$this->setName('sfError40xException');
30+
parent::__construct($message, $code);
31+
}
32+
33+
/**
34+
* Forwards to the 40x action.
35+
*
36+
* @param Exception An Exception implementation instance
37+
*/
38+
public function printStackTrace($exception = null)
39+
{
40+
$sfContext = sfContext::getInstance();
41+
$sfContext->getRequest()->setParameter('message', $this->getMessage());
42+
$sfContext->getController()->forward(sfConfig::get('sf_error_40x_module'), sfConfig::get('sf_error_40x_action'));
43+
}
44+
}

0 commit comments

Comments
 (0)