2013-04-22 04:09:50 +00:00
|
|
|
<?php defined('SYSPATH') OR die('No direct script access.');
|
|
|
|
|
|
|
|
abstract class Kohana_HTTP_Exception extends Kohana_Exception {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates an HTTP_Exception of the specified type.
|
2014-09-06 13:43:07 +00:00
|
|
|
*
|
2013-04-22 04:09:50 +00:00
|
|
|
* @param integer $code the http status code
|
|
|
|
* @param string $message status message, custom content to display with error
|
|
|
|
* @param array $variables translation variables
|
|
|
|
* @return HTTP_Exception
|
|
|
|
*/
|
|
|
|
public static function factory($code, $message = NULL, array $variables = NULL, Exception $previous = NULL)
|
|
|
|
{
|
|
|
|
$class = 'HTTP_Exception_'.$code;
|
2014-09-06 13:43:07 +00:00
|
|
|
|
2013-04-22 04:09:50 +00:00
|
|
|
return new $class($message, $variables, $previous);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var int http status code
|
|
|
|
*/
|
|
|
|
protected $_code = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var Request Request instance that triggered this exception.
|
|
|
|
*/
|
|
|
|
protected $_request;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a new translated exception.
|
|
|
|
*
|
|
|
|
* throw new Kohana_Exception('Something went terrible wrong, :user',
|
|
|
|
* array(':user' => $user));
|
|
|
|
*
|
|
|
|
* @param string $message status message, custom content to display with error
|
|
|
|
* @param array $variables translation variables
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function __construct($message = NULL, array $variables = NULL, Exception $previous = NULL)
|
|
|
|
{
|
|
|
|
parent::__construct($message, $variables, $this->_code, $previous);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Store the Request that triggered this exception.
|
2014-09-06 13:43:07 +00:00
|
|
|
*
|
2013-04-22 04:09:50 +00:00
|
|
|
* @param Request $request Request object that triggered this exception.
|
2014-09-06 13:43:07 +00:00
|
|
|
* @return HTTP_Exception
|
2013-04-22 04:09:50 +00:00
|
|
|
*/
|
|
|
|
public function request(Request $request = NULL)
|
|
|
|
{
|
|
|
|
if ($request === NULL)
|
|
|
|
return $this->_request;
|
2014-09-06 13:43:07 +00:00
|
|
|
|
2013-04-22 04:09:50 +00:00
|
|
|
$this->_request = $request;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Generate a Response for the current Exception
|
2014-09-06 13:43:07 +00:00
|
|
|
*
|
2013-04-22 04:09:50 +00:00
|
|
|
* @uses Kohana_Exception::response()
|
|
|
|
* @return Response
|
|
|
|
*/
|
|
|
|
public function get_response()
|
|
|
|
{
|
|
|
|
return Kohana_Exception::response($this);
|
|
|
|
}
|
|
|
|
|
2014-09-06 13:43:07 +00:00
|
|
|
}
|