Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create a Rest_Exception class and use it to convey status to the clie…
…nt instead of calling rest::forbidden and other rest helper error messages.
- Loading branch information
Tim Almdal
committed
Dec 31, 2009
1 parent
732047e
commit 1a12a5e
Showing
6 changed files
with
109 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters