So, to consolidate what Westie says, the important part is that you can have only one error handler, and the set_error_handler () function returns the previously defined error handler or null if none are defined. Therefore, in error handlers, perhaps use the class that stores the previous error handler when registering it, so when you handle errors using the class method, call the previous error handler. Excerpt from raven-php chat client:
public function registerErrorHandler($call_existing_error_handler = true, $error_types = -1) { $this->error_types = $error_types; $this->old_error_handler = set_error_handler(array($this, 'handleError'), error_reporting()); $this->call_existing_error_handler = $call_existing_error_handler; }
and then the descriptor error method:
public function handleError($code, $message, $file = '', $line = 0, $context=array()) { if ($this->error_types & $code & error_reporting()) { $e = new ErrorException($message, 0, $code, $file, $line); $this->handleException($e, true, $context); } if ($this->call_existing_error_handler && $this->old_error_handler) { call_user_func($this->old_error_handler, $code, $message, $file, $line, $context); } }
source share