/**
  * Get the current user.
  *
  * @return array
  */
 public function getUser()
 {
     $defaultUser = array();
     $userId = Bugsnag_Request::getUserId();
     if (!is_null($userId)) {
         $defaultUser['id'] = $userId;
     }
     return $this->config->get('user', $defaultUser);
 }
 /**
  * Deliver everything on the queue to Bugsnag.
  *
  * @return void
  */
 public function deliver()
 {
     if (empty($this->errorQueue)) {
         return;
     }
     // Post the request to bugsnag
     $this->postJSON($this->config->getNotifyEndpoint(), $this->toArray());
     // Clear the error queue
     $this->errorQueue = array();
 }
Example #3
0
 public function testStrippingPaths()
 {
     $fixture = $this->getJsonFixture('backtraces/exception_handler.json');
     $this->config->setStripPath("/Users/james/src/bugsnag/bugsnag-php/");
     $stacktrace = Bugsnag_Stacktrace::fromBacktrace($this->config, $fixture['backtrace'], $fixture['file'], $fixture['line'])->toArray();
     $this->assertCount(3, $stacktrace);
     $this->assertFrameEquals($stacktrace[0], "crashy_function", "testing.php", 25);
     $this->assertFrameEquals($stacktrace[1], "parent_of_crashy_function", "testing.php", 13);
     $this->assertFrameEquals($stacktrace[2], "[main]", "testing.php", 28);
 }
 /**
  * Shutdown handler callback.
  *
  * Called when the PHP process has finished running. Should only be called
  * internally by PHP's register_shutdown_function.
  *
  * @return void
  */
 public function shutdownHandler()
 {
     // Get last error
     $lastError = error_get_last();
     // Check if a fatal error caused this shutdown
     if (!is_null($lastError) && Bugsnag_ErrorTypes::isFatal($lastError['type']) && $this->config->autoNotify && !$this->config->shouldIgnoreErrorCode($lastError['type'])) {
         $error = Bugsnag_Error::fromPHPError($this->config, $this->diagnostics, $lastError['type'], $lastError['message'], $lastError['file'], $lastError['line'], true);
         $error->setSeverity('error');
         $this->notify($error);
     }
     // Flush any buffered errors
     if ($this->notification) {
         $this->notification->deliver();
         $this->notification = null;
     }
 }
 public function testShouldNotIgnore()
 {
     $this->config->errorReportingLevel = E_ALL;
     $this->assertfalse($this->config->shouldIgnoreErrorCode(E_NOTICE));
 }