mirror of
https://github.com/Pathduck/gallery3.git
synced 2026-05-19 19:09:13 -04:00
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.
This commit is contained in:
@@ -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";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user