public function __construct($exceptionCode, $exceptionMessage)
 {
     parent::__construct($exceptionMessage, (int) $exceptionCode);
     $this->code = $exceptionCode;
     $this->message = $exceptionMessage;
     try {
         // Gets the matching HTTP Status code for the exception code
         list($code_string, $httpStatusCode) = pa_get_error_name($this->code);
         if (isset($httpStatusCode)) {
             // set http header error code
             header(HttpStatusCodes::httpHeaderFor($httpStatusCode));
             // log the occrance in php error log
             //user_error(print_r($httpStatusCode, true), E_USER_WARNING);
         }
     } catch (Exception $ex) {
         // ignore this exception. No need to throw it since the HttpStatusCode is
         // not important enough to throw over the real exception
     }
     try {
         global $app;
         $hoptoad_key = $app->configData['configuration']['api_keys']['value']['hoptoad_key']['value'];
         $hoptoad_env = $app->configData['configuration']['api_keys']['value']['hoptoad_env']['value'];
         if (isset($hoptoad_key) && !empty($hoptoad_key) && isset($hoptoad_env) && !empty($hoptoad_env)) {
             $hoptoad = new Services_Hoptoad($hoptoad_key, $hoptoad_env, 'curl');
             $hoptoad->exceptionHandler($this);
         }
     } catch (Exception $e) {
         // ignore exception since posting to Hoptoad is not fatal
     }
 }
Example #2
0
// register Services_Hoptoad for php errors and raised exceptions
// when used in your staging environment
require_once 'Services/Hoptoad.php';
Services_Hoptoad::installHandlers("YOUR_HOPTOAD_API_KEY", 'staging');
?>

<?php 
// register Services_Hoptoad for php errors and raised exceptions
// when used in production and using the Curl transport
require_once 'Services/Hoptoad.php';
Services_Hoptoad::installHandlers("YOUR_HOPTOAD_API_KEY", 'production', 'curl');
?>
 
<?php 
// standalone
require_once 'Services/Hoptoad.php';
Services_Hoptoad::$apiKey = "YOUR_HOPTOAD_API_KEY";
$exception = new Custom_Exception('foobar');
Services_Hoptoad::handleException($exception);
?>
 
<?php 
// use Zend_Http_Client
require_once 'Services/Hoptoad.php';
Services_Hoptoad::$apiKey = "YOUR_HOPTOAD_API_KEY";
Services_Hoptoad::$client = "zend";
$exception = new Custom_Exception('foobar');
Services_Hoptoad::handleException($exception);
?>