/** * @param \Doctrine\Common\Annotations\AnnotationException $e * * @return string */ public static function highlightAnnotationLine(AnnotationException $e) { foreach ($e->getTrace() as $step) { if (@$step['class'] . @$step['type'] . @$step['function'] !== 'Doctrine\\Common\\Annotations\\DocParser->parse') { continue; } $context = Strings::match($step['args'][1], '~^(?P<type>[^\\s]+)\\s*(?P<class>[^:]+)(?:::\\$?(?P<property>[^\\(]+))?$~i'); break; } if (!isset($context)) { return FALSE; } $refl = Nette\Reflection\ClassType::from($context['class']); $file = $refl->getFileName(); $line = NULL; if ($context['type'] === 'property') { $refl = $refl->getProperty($context['property']); $line = Kdyby\Doctrine\Helpers::getPropertyLine($refl); } elseif ($context['type'] === 'method') { $refl = $refl->getProperty($context['method']); } if (($errorLine = self::calculateErrorLine($refl, $e, $line)) === NULL) { return FALSE; } $dump = BlueScreen::highlightFile($file, $errorLine); return '<p><b>File:</b> ' . self::editorLink($file, $errorLine) . '</p>' . $dump; }
public static function initialize() { $blueScreen = Tracy\Debugger::getBlueScreen(); if (preg_match('#(.+)/Bridges/Framework$#', strtr(__DIR__, '\\', '/'), $m)) { if (preg_match('#(.+)/nette/bootstrap/src$#', $m[1], $m2)) { $blueScreen->collapsePaths[] = "{$m2['1']}/nette"; $blueScreen->collapsePaths[] = "{$m2['1']}/latte"; } else { $blueScreen->collapsePaths[] = $m[1]; } } if (class_exists('Nette\\Framework')) { $bar = Tracy\Debugger::getBar(); $bar->info[] = $blueScreen->info[] = 'Nette Framework ' . Nette\Framework::VERSION . ' (' . Nette\Framework::REVISION . ')'; } $blueScreen->addPanel(function ($e) { if ($e instanceof Latte\CompileException) { return array('tab' => 'Template', 'panel' => '<p>' . (is_file($e->sourceName) ? '<b>File:</b> ' . Helpers::editorLink($e->sourceName, $e->sourceLine) : htmlspecialchars($e->sourceName)) . '</p>' . ($e->sourceCode ? '<pre>' . BlueScreen::highlightLine(htmlspecialchars($e->sourceCode), $e->sourceLine) . '</pre>' : '')); } elseif ($e instanceof Nette\Neon\Exception && preg_match('#line (\\d+)#', $e->getMessage(), $m)) { if ($item = Helpers::findTrace($e->getTrace(), 'Nette\\DI\\Config\\Adapters\\NeonAdapter::load')) { return array('tab' => 'NEON', 'panel' => '<p><b>File:</b> ' . Helpers::editorLink($item['args'][0], $m[1]) . '</p>' . BlueScreen::highlightFile($item['args'][0], $m[1])); } elseif ($item = Helpers::findTrace($e->getTrace(), 'Nette\\Neon\\Decoder::decode')) { return array('tab' => 'NEON', 'panel' => BlueScreen::highlightPhp($item['args'][0], $m[1])); } } }); }
/** * @param \Kdyby\Autowired\Exception $e * @return string */ protected static function highlightException(Kdyby\Autowired\Exception $e) { $refl = $e->getReflector(); /** @var \Reflector|\Nette\Reflection\Property|\Nette\Reflection\Method $refl */ $file = $refl->getDeclaringClass()->getFileName(); $line = $refl instanceof Nette\Reflection\Property ? self::getPropertyLine($refl) : $refl->getStartLine(); return '<p><b>File:</b> ' . Helpers::editorLink($file, $line) . '</p>' . BlueScreen::highlightFile($file, $line); }
public static function initialize() { $blueScreen = Tracy\Debugger::getBlueScreen(); if (class_exists('Nette\\Framework')) { $version = Framework::VERSION . (Framework::REVISION ? ' (' . Framework::REVISION . ')' : ''); Tracy\Debugger::getBar()->getPanel('Tracy:info')->data['Nette Framework'] = $version; $blueScreen->info[] = "Nette Framework {$version}"; } $blueScreen->addPanel(function ($e) { if ($e instanceof Latte\CompileException) { return ['tab' => 'Template', 'panel' => (@is_file($e->sourceName) ? '<p><b>File:</b> ' . Helpers::editorLink($e->sourceName, $e->sourceLine) . '</p>' : '') . '<pre>' . BlueScreen::highlightLine(htmlspecialchars($e->sourceCode, ENT_IGNORE, 'UTF-8'), $e->sourceLine) . '</pre>']; } }); $blueScreen->addPanel(function ($e) { if ($e instanceof Nette\Neon\Exception && preg_match('#line (\\d+)#', $e->getMessage(), $m) && ($trace = Helpers::findTrace($e->getTrace(), 'Nette\\Neon\\Decoder::decode'))) { return ['tab' => 'NEON', 'panel' => ($trace2 = Helpers::findTrace($e->getTrace(), 'Nette\\DI\\Config\\Adapters\\NeonAdapter::load')) ? '<p><b>File:</b> ' . Helpers::editorLink($trace2['args'][0], $m[1]) . '</p>' . BlueScreen::highlightFile($trace2['args'][0], $m[1]) : BlueScreen::highlightPhp($trace['args'][0], $m[1])]; } }); }
public static function initialize() { $bar = Tracy\Debugger::getBar(); $bar->info[] = 'Nette Framework ' . Nette\Framework::VERSION . ' (' . substr(Nette\Framework::REVISION, 8) . ')'; $blueScreen = Tracy\Debugger::getBlueScreen(); $blueScreen->collapsePaths[] = dirname(dirname(__DIR__)); $blueScreen->info[] = 'Nette Framework ' . Nette\Framework::VERSION . ' (revision ' . Nette\Framework::REVISION . ')'; $blueScreen->addPanel(function ($e) { if ($e instanceof Latte\CompileException) { return array('tab' => 'Template', 'panel' => '<p>' . (is_file($e->sourceName) ? '<b>File:</b> ' . Helpers::editorLink($e->sourceName, $e->sourceLine) : htmlspecialchars($e->sourceName)) . '</p>' . ($e->sourceCode ? '<pre>' . BlueScreen::highlightLine(htmlspecialchars($e->sourceCode), $e->sourceLine) . '</pre>' : '')); } elseif ($e instanceof Nette\Utils\NeonException && preg_match('#line (\\d+)#', $e->getMessage(), $m)) { if ($item = Helpers::findTrace($e->getTrace(), 'Nette\\DI\\Config\\Adapters\\NeonAdapter::load')) { return array('tab' => 'NEON', 'panel' => '<p><b>File:</b> ' . Helpers::editorLink($item['args'][0], $m[1]) . '</p>' . BlueScreen::highlightFile($item['args'][0], $m[1])); } elseif ($item = Helpers::findTrace($e->getTrace(), 'Nette\\Utils\\Neon::decode')) { return array('tab' => 'NEON', 'panel' => BlueScreen::highlightPhp($item['args'][0], $m[1])); } } }); }
public static function renderException($e = NULL) { if (!$e instanceof InvalidResourceException || !($previous = $e->getPrevious())) { return NULL; } $previous = $previous->getPrevious(); if (!$previous instanceof Yaml\Exception\ParseException) { return NULL; } $method = 'Symfony\\Component\\Translation\\Loader\\YamlFileLoader::load'; if ($call = Helpers::findTrace($e->getPrevious()->getTrace(), $method)) { return array('tab' => 'YAML dictionary', 'panel' => '<p><b>File:</b> ' . self::editorLink($call['args'][0], $previous->getParsedLine()) . '</p>' . ($previous->getParsedLine() ? BlueScreen::highlightFile($call['args'][0], $previous->getParsedLine()) : '') . '<p>' . $previous->getMessage() . ' </p>'); } }
public static function addPanel($e) { if ($e instanceof \obo\Exceptions\Exception && $e->foreseenFileError !== null && $e->foreseenLineError !== null) { return ["tab" => "Foreseen Error", "panel" => \Tracy\BlueScreen::highlightFile($e->foreseenFileError, (int) $e->foreseenLineError, 20)]; } }
/** * Renders SQL query string to Nette debug bluescreen when available. * @param NeevoException $e * @return array */ public function renderException($e) { if (!($e instanceof NeevoException && $e->getSql())) { return; } list($file, $line) = $this->failedQuerySource; return array('tab' => 'SQL', 'panel' => Manager::highlightSql($e->getSql()) . '<p><b>File:</b> ' . Helpers::editorLink($file, $line) . " <b>Line:</b> {$line}</p>" . ($line ? BlueScreen::highlightFile($file, $line) : '') . 'Neevo v' . Manager::VERSION); }