Skip to content
Browse files

Keep the old error handler, and call it once Airbrake is done

  • Loading branch information...
1 parent ff40730 commit a215cf1393e7538a16eb14dfc47c6df51f10e43f @snikch snikch committed Oct 10, 2011
Showing with 19 additions and 7 deletions.
  1. +19 −7 Services/Airbrake.php
View
26 Services/Airbrake.php
@@ -52,6 +52,12 @@ class Services_Airbrake
public $environment;
/**
+ * @vars object previous error handlers
+ **/
+ protected $previous_error_handler;
+ protected $previous_exception_handler;
+
+ /**
* Initialize the chosen notifier and install the error
* and exception handlers that connect to Airbrake
*
@@ -84,8 +90,8 @@ public static function setBlacklist($array)
public function installNotifierHandlers()
{
register_shutdown_function(array($this, "fatalErrorHandler"));
- set_error_handler(array($this, "errorHandler"));
- set_exception_handler(array($this, "exceptionHandler"));
+ $this->previous_error_handler = set_error_handler(array($this, "errorHandler"));
+ $this->previous_exception_handler = set_exception_handler(array($this, "exceptionHandler"));
}
/**
@@ -123,10 +129,10 @@ public function setup()
/**
* Handle a php error
*
- * @param string $code
- * @param string $message
- * @param string $file
- * @param string $line
+ * @param string $code
+ * @param string $message
+ * @param string $file
+ * @param string $line
* @return void
* @author Rich Cavanaugh
*/
@@ -135,18 +141,24 @@ public function errorHandler($code, $message, $file, $line)
if ($code == E_STRICT && $this->reportESTRICT === false) return;
$this->notify($code, $message, $file, $line, debug_backtrace());
+
+ if($this->previous_error_handler)
+ call_user_func($this->previous_error_handler, $code, $message, $file, $line);
}
/**
* Handle a raised exception
*
- * @param Exception $exception
+ * @param Exception $exception
* @return void
* @author Rich Cavanaugh
*/
public function exceptionHandler($exception)
{
$this->notify(get_class($exception), $exception->getMessage(), $exception->getFile(), $exception->getLine(), $exception->getTrace());
+
+ if($this->previous_exception_handler)
+ call_user_func($this->previous_exception_handler, $exception);
}
/**

0 comments on commit a215cf1

Please sign in to comment.
Something went wrong with that request. Please try again.