function exception_error_handler($errno, $errstr, $errfile, $errline ) {
throw new PluginErrorException($errstr, 0, $errno, $errfile, $errline);
}
-set_error_handler("exception_error_handler", E_ALL);
/* the Exceptionhandler for Syntax-Errors, throwed by PHP itself */
/**
*
* @category Plugin
* @package StatusNet
- * @author Leon Giesenkaemper <leon@darksider3.de>
+ * @author Craig Andrews <candrews@integralblue.com>
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://darksider3.de/sn/urlshortenerplugin2.html
*/
{
try
{
- //Or create exception here, by looking for 'false'...? Hmm..
- //No, let HTTPClient throw it. But then we need a more generally
- //Exception system.
$request = HTTPClient::start();
$response = $request->get($url);
-
} catch(PluginErrorException $e)
{
$e->printFull();
*
* @return string response body
*
- * @todo self with exceptions as in httpGet()
*/
protected function httpPost($url, $data)
{
- try{
- $request = HTTPClient::start();
- $response = $request->post($url, null, $data);
-
- } catch(PluginErrorException $e)
- {
- $e->printFull();
- return false;
- }
+
+ $request = HTTPClient::start();
+ $response = $request->post($url, null, $data);
return $response->getBody();
}
// Hook handlers
{
$shortenedUrl = $result;
//dont create an exception, so we can do that without.
- //If needed, i can code done..but actually it seems useless to do that.
common_log(LOG_INFO,
__CLASS__ . ": $this->shortenerName ".
"shortened $url to $shortenedUrl");
return true;
}
}
-//@debug
-function A() {
- $foo->bar(); // Purposely cause error
-}
-
-function B($c) {
- A();
-}
-
-try {
- B('foobar');
-} catch (PluginErrorException $e) {
- echo $e->printFull();
-}
?>