summaryrefslogtreecommitdiff
path: root/modules/rest/libraries
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2010-06-19 13:53:22 -0700
committerBharat Mediratta <bharat@menalto.com>2010-06-19 14:07:37 -0700
commit456d54ea2dccbe55a2efd89ecb4bde29fb91b619 (patch)
tree91e7b71f4b167e99fa3e0494d358e9787300d0df /modules/rest/libraries
parent41ca2b0195bf6a29429dfc5405f3c2073b1c3aba (diff)
Throw exceptions as appropriate, but allow the Kohana exception
handling framework to handle the exception and delegate to our template, which will JSON encode the response.
Diffstat (limited to 'modules/rest/libraries')
-rw-r--r--modules/rest/libraries/Rest_Exception.php11
1 files changed, 9 insertions, 2 deletions
diff --git a/modules/rest/libraries/Rest_Exception.php b/modules/rest/libraries/Rest_Exception.php
index aa5b3281..c5baec63 100644
--- a/modules/rest/libraries/Rest_Exception.php
+++ b/modules/rest/libraries/Rest_Exception.php
@@ -18,13 +18,20 @@
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class Rest_Exception_Core extends Kohana_Exception {
- public function __construct($message, $code) {
+ var $response = array();
+
+ public function __construct($message, $code, $response) {
parent::__construct($message, null, $code);
+ $this->response = $response;
}
public function sendHeaders() {
if (!headers_sent()) {
- header("HTTP/1.1 " . $this->getCode() . "Bad Request");
+ header("HTTP/1.1 " . $this->getCode() . " " . $this->getMessage());
}
}
+
+ public function getTemplate() {
+ return "error_rest";
+ }
} \ No newline at end of file