diff options
Diffstat (limited to 'modules/rest/libraries/Rest_Exception.php')
-rw-r--r-- | modules/rest/libraries/Rest_Exception.php | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/modules/rest/libraries/Rest_Exception.php b/modules/rest/libraries/Rest_Exception.php new file mode 100644 index 00000000..acdcb568 --- /dev/null +++ b/modules/rest/libraries/Rest_Exception.php @@ -0,0 +1,41 @@ +<?php defined('SYSPATH') OR die('No direct access allowed.'); +/** + * Creates a "Page Not Found" exception. + * + * $Id: Kohana_404_Exception.php 4679 2009-11-10 01:45:52Z isaiah $ + * + * @package Core + * @author Kohana Team + * @copyright (c) 2007-2009 Kohana Team + * @license http://kohanaphp.com/license + */ + +class Rest_Exception_Core extends Exception { + /** + * Set internal properties. + */ + public function __construct($code, $text) { + parent::__construct("$code $text"); + } + + /** + * Throws a new Rest exception. + * + * @throws Rest_Exception + * @return void + */ + public static function trigger($code, $text, $log_message=null) { + $message = "$code: $text" . (!empty($log_message) ? "\n$log_message" : ""); + Kohana_Log::add("info", $message); + throw new Rest_Exception($code, $text); + } + + /** + * Sends the headers, to emulate server behavior. + * + * @return void + */ + public function sendHeaders() { + header('HTTP/1.1 {$this->getMessage()}'); + } +} // End Rest Exception
\ No newline at end of file |