diff options
author | Bharat Mediratta <bharat@menalto.com> | 2010-01-19 23:28:18 -0800 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2010-01-19 23:28:18 -0800 |
commit | 92d96548e9b365cfa8e888a2103ab09e9f45914a (patch) | |
tree | cf2e9b433c672cff84d175c111b85c204c8ae744 | |
parent | 76da85a1a08cdf065bf186c81ea444d03d6f8935 (diff) |
Make Rest_Exception extend Kohana_Exception so that we can let it
bubble to the top and then in sendHeaders have it send the right
response code.
-rw-r--r-- | modules/rest/libraries/Rest_Exception.php | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/modules/rest/libraries/Rest_Exception.php b/modules/rest/libraries/Rest_Exception.php index 596b3712..c3548b7e 100644 --- a/modules/rest/libraries/Rest_Exception.php +++ b/modules/rest/libraries/Rest_Exception.php @@ -17,5 +17,14 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ -class Rest_Exception_Core extends Exception { +class Rest_Exception_Core extends Kohana_Exception { + public function __construct($message, $code) { + parent::__construct($message, null, $code); + } + + public function sendHeaders() { + if (!headers_sent()) { + header("HTTP/1.1 " . $this->getCode() . " " . $this->getMessage()); + } + } }
\ No newline at end of file |