Пример #1
0
 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;
 }
Пример #2
0
 public static function fromBacktrace($config, $backtrace, $topFile, $topLine)
 {
     $stacktrace = new Bugsnag_Stacktrace($config);
     // PHP backtrace's are misaligned, we need to shift the file/line down a frame
     foreach ($backtrace as $frame) {
         if (!self::frameInsideBugsnag($frame)) {
             $stacktrace->addFrame($topFile, $topLine, isset($frame['function']) ? $frame['function'] : null, isset($frame['class']) ? $frame['class'] : null);
         }
         if (isset($frame['file']) && isset($frame['line'])) {
             $topFile = $frame['file'];
             $topLine = $frame['line'];
         } else {
             $topFile = "[internal]";
             $topLine = 0;
         }
     }
     // Add a final stackframe for the "main" method
     $stacktrace->addFrame($topFile, $topLine, '[main]');
     return $stacktrace;
 }
 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()]);
 }
Пример #4
0
 public function setPHPError($code, $message, $file, $line, $fatal = false)
 {
     if ($fatal) {
         // Generating stacktrace for PHP fatal errors is not possible,
         // since this code executes when the PHP process shuts down,
         // rather than at the time of the crash.
         //
         // In these situations, we generate a "stacktrace" containing only
         // the line and file number where the crash occurred.
         $stacktrace = Bugsnag_Stacktrace::fromFrame($this->config, $file, $line);
     } else {
         $stacktrace = Bugsnag_Stacktrace::generate($this->config);
     }
     $this->setName(Bugsnag_ErrorTypes::getName($code))->setMessage($message)->setSeverity(Bugsnag_ErrorTypes::getSeverity($code))->setStacktrace($stacktrace)->setCode($code);
     return $this;
 }
Пример #5
0
 public function testCodeDisabled()
 {
     $config = new Bugsnag_Configuration();
     $config->sendCode = false;
     $stacktrace = Bugsnag_Stacktrace::fromFrame($config, $this->getFixturePath('code/File.php'), 1)->toArray();
     $this->assertCount(1, $stacktrace);
     $topFrame = $stacktrace[0];
     $this->assertArrayNotHasKey('code', $topFrame);
 }