public function beforeBugsnagNotify(\Bugsnag_Error $error) { if (!$this->exportingLog) { Yii::getLogger()->flush(true); } if (isset($error->metaData['trace'])) { $trace = $error->metaData['trace']; unset($error->metaData['trace']); if (!empty($trace)) { $firstFrame = array_shift($trace); $error->setStacktrace(\Bugsnag_Stacktrace::fromBacktrace($error->config, $trace, $firstFrame['file'], $firstFrame['line'])); } } $error->setMetaData(['logs' => BugsnagLogTarget::getMessages()]); }
public function exceptionArray() { if ($this->previous) { $exceptionArray = $this->previous->exceptionArray(); } else { $exceptionArray = array(); } $exceptionArray[] = array('errorClass' => $this->name, 'message' => $this->message, 'stacktrace' => $this->stacktrace->toArray()); return $exceptionArray; }
public function testPreviousException() { if (version_compare(PHP_VERSION, '5.3.0', '>=')) { $exception = new Exception("secondly", 65533, new Exception("firstly")); $error = Bugsnag_Error::fromPHPException($this->config, $this->diagnostics, $exception); $errorArray = $error->toArray(); $this->assertEquals(count($errorArray['exceptions']), 2); $this->assertEquals($errorArray['exceptions'][0]['message'], 'firstly'); $this->assertEquals($errorArray['exceptions'][1]['message'], 'secondly'); } }
/** * Add an error to the queue. * * @param Bugsnag_Error $config the bugsnag error instance * @param array $passedMetaData the associated meta data * * @return bool */ public function addError(Bugsnag_Error $error, $passedMetaData = array()) { // Check if this error should be sent to Bugsnag if (!$this->config->shouldNotify()) { return false; } // Add global meta-data to error $error->setMetaData($this->config->metaData); // Add request meta-data to error if (Bugsnag_Request::isRequest()) { $error->setMetaData(Bugsnag_Request::getRequestMetaData()); } // Session Tab if ($this->config->sendSession && !empty($_SESSION)) { $error->setMetaData(array('session' => $_SESSION)); } // Cookies Tab if ($this->config->sendCookies && !empty($_COOKIE)) { $error->setMetaData(array('cookies' => $_COOKIE)); } // Add environment meta-data to error if ($this->config->sendEnvironment && !empty($_ENV)) { $error->setMetaData(array('Environment' => $_ENV)); } // Add user-specified meta-data to error $error->setMetaData($passedMetaData); // Run beforeNotify function (can cause more meta-data to be merged) if (isset($this->config->beforeNotifyFunction) && is_callable($this->config->beforeNotifyFunction)) { $beforeNotifyReturn = call_user_func($this->config->beforeNotifyFunction, $error); } // Skip this error if the beforeNotify function returned FALSE if (!isset($beforeNotifyReturn) || $beforeNotifyReturn !== false) { $this->errorQueue[] = $error; return true; } else { return false; } }
public function setPrevious($exception) { if ($exception) { $this->previous = Bugsnag_Error::fromPHPException($this->config, $this->diagnostics, $exception); } return $this; }
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 testErrorGroupingHashNotSet() { $errorArray = $this->error->toArray(); $this->assertArrayNotHasKey('groupingHash', $errorArray); }
protected function getError($name = "Name", $message = "Message") { return Bugsnag_Error::fromNamedError($this->config, $this->diagnostics, $name, $message); }