public static function handle($code, $error, $file = NULL, $line = NULL) { if (error_reporting() & $code) { // This error is not suppressed by current error reporting settings. // Convert the error into an ErrorException. $exception = new \ErrorException($error, $code, 0, $file, $line); // Send the error to Honeybadger. Honeybadger::notify_or_ignore($exception); } if (is_callable(self::$previous_handler)) { // Pass the triggered error on to the previous error handler. return call_user_func(self::$previous_handler, $code, $error, $file, $line); } // Execute the PHP error handler. return FALSE; }
public static function handle(\Exception $e) { try { // Attempt to send this exception to Honeybadger. Honeybadger::notify_or_ignore($e); } catch (Exception $e) { if (is_callable(self::$previous_handler)) { return call_user_func(self::$previous_handler, $e); } else { // Clean the output buffer if one exists. ob_get_level() and ob_clean(); // Set the Status code to 500, and Content-Type to text/plain. header('Content-Type: text/plain; charset=utf-8', TRUE, 500); echo 'Someting went terribly wrong.'; // Exit with a non-zero status. exit(1); } } if (is_callable(self::$previous_handler)) { return call_user_func(self::$previous_handler, $e); } }
public function test_notify_or_ignore_does_not_notify_when_ignored() { Honeybadger::$config->ignore = array('Exception'); $this->assertEmpty(Honeybadger::notify_or_ignore($this->build_exception())); }