/**
  * Handles the PHP shutdown event.
  *
  * This event exists almost soley to provide a means to catch and log errors that might have been
  * otherwise lost when PHP decided to die unexpectedly.
  */
 public function onShutdown()
 {
     // If the instance was unset, then we shouldn't run.
     if (self::$instance == null) {
         return;
     }
     // This will help prevent multiple calls to this, incase the shutdown handler was declared
     // multiple times. This only should occur in unit tests, when the handlers are created
     // and removed repeatedly. As we cannot remove shutdown handlers, this prevents us from
     // calling it 1000 times at the end.
     self::$instance = null;
     // Get the last error if there was one, if not, let's get out of here.
     if (!($error = error_get_last())) {
         return;
     }
     $message = 'It looks like we may have shutdown unexpectedly. Here is the error ' . 'we saw while closing up: %s  File: %s  Line: %d';
     $message = sprintf($message, $error['message'], $error['file'], $error['line']);
     $this->airbrakeClient->notifyOnError($message);
 }
Ejemplo n.º 2
0
 /**
  * Handles the PHP shutdown event.
  *
  * This event exists almost soley to provide a means to catch and log errors that might have been
  * otherwise lost when PHP decided to die unexpectedly.
  */
 public function onShutdown()
 {
     // If the instance was unset, then we shouldn't run.
     if (self::$instance == null) {
         return;
     }
     // This will help prevent multiple calls to this, incase the shutdown handler was declared
     // multiple times. This only should occur in unit tests, when the handlers are created
     // and removed repeatedly. As we cannot remove shutdown handlers, this prevents us from
     // calling it 1000 times at the end.
     self::$instance = null;
     // Get the last error if there was one, if not, let's get out of here.
     if (!($error = error_get_last())) {
         return;
     }
     // Don't notify on warning if not configured to.
     if (!$this->shouldNotifyError($error['type'], $error['message'], $error['file'], $error['line'])) {
         return;
     }
     // Build a fake backtrace, so we at least can show where we came from.
     $backtrace = array(array('file' => $error['file'], 'line' => $error['line'], 'function' => '', 'args' => array()));
     $this->airbrakeClient->notifyOnError('[Improper Shutdown] ' . $error['message'], $backtrace);
 }