public function setPHPException(Exception $exception) { $this->setName(get_class($exception))->setMessage($exception->getMessage())->setStacktrace(Bugsnag_Stacktrace::fromBacktrace($this->config, $exception->getTrace(), $exception->getFile(), $exception->getLine())); if (method_exists($exception, 'getPrevious')) { $this->setPrevious($exception->getPrevious()); } return $this; }
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()]); }
/** * Set the PHP throwable. * * @param Throwable $exception the throwable instance * * @return $this */ public function setPHPThrowable($exception) { if (version_compare(PHP_VERSION, '7.0.0', '>=')) { if (!$exception instanceof Throwable) { error_log('Bugsnag Warning: The exception must implement Throwable.'); return $this; } } else { if (!$exception instanceof Exception) { error_log('Bugsnag Warning: The exception must be an Exception.'); return $this; } } $this->setName(get_class($exception))->setMessage($exception->getMessage())->setStacktrace(Bugsnag_Stacktrace::fromBacktrace($this->config, $exception->getTrace(), $exception->getFile(), $exception->getLine())); if (method_exists($exception, 'getPrevious')) { $this->setPrevious($exception->getPrevious()); } return $this; }
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); }