Improved exception handling and other minor fixes
This commit is contained in:
15
application/classes/HTTP/Exception/403.php
Normal file
15
application/classes/HTTP/Exception/403.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class overrides Kohana's 403 Exception
|
||||
*
|
||||
* @package OSB
|
||||
* @category Exceptions
|
||||
* @author Deon George
|
||||
* @copyright (c) 2009-2013 Open Source Billing
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
class HTTP_Exception_403 extends HTTP_Exception {
|
||||
protected $_code = 403;
|
||||
}
|
||||
?>
|
@@ -9,17 +9,7 @@
|
||||
* @copyright (c) 2009-2013 Open Source Billing
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
class HTTP_Exception_404 extends Kohana_HTTP_Exception_404 {
|
||||
public function get_response() {
|
||||
$response = Response::factory();
|
||||
$response->status($this->_code);
|
||||
|
||||
$view = View::factory('errors/404');
|
||||
$view->message = $this->getMessage();
|
||||
|
||||
$response->body($view->render());
|
||||
|
||||
return $response;
|
||||
}
|
||||
class HTTP_Exception_404 extends HTTP_Exception {
|
||||
protected $_code = 404;
|
||||
}
|
||||
?>
|
||||
|
@@ -1,7 +1,7 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class provides a custom 501 Exception to catch OSB specific errors.
|
||||
* This class overrides Kohana's 501 Exception to catch OSB specific errors
|
||||
*
|
||||
* @package OSB
|
||||
* @category Exceptions
|
||||
@@ -9,26 +9,7 @@
|
||||
* @copyright (c) 2009-2013 Open Source Billing
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
class HTTP_Exception_501 extends Kohana_HTTP_Exception {
|
||||
class HTTP_Exception_501 extends HTTP_Exception {
|
||||
protected $_code = 501;
|
||||
|
||||
public function __construct($message='',array $variables=NULL,$code=0) {
|
||||
parent::__construct($message,$variables,$code);
|
||||
|
||||
$response = Response::factory();
|
||||
$response->status($this->_code);
|
||||
|
||||
// @todo This is not working as cleanly as I would like - ie: we shouldnt need to publish the headers ourselves?
|
||||
header(':', true, 501);
|
||||
|
||||
if (Kohana::$config->load('debug')->show_errors)
|
||||
$response->body(View::factory('errors/501')->set('message',$this->getMessage())->render());
|
||||
else
|
||||
$response->body('Dang, something went wrong, tell us how we got here...');
|
||||
|
||||
echo $response->render();
|
||||
|
||||
exit (501);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
Reference in New Issue
Block a user