public function showCallLocation() { $namespace = Debug::libraryNamespace(); $base = __DIR__; $stack = debug_backtrace(0); $FNS = self::GLOBAL_LOG_FNS; // Discard frames of all functions that belong to this library. while (!empty($stack) && (isset($stack[0]['file']) && stripos($stack[0]['file'], $base) === 0 || isset($stack[0]['class']) && stripos($stack[0]['class'], $namespace) === 0 || isset($stack[0]['function']) && !isset($FNS[$stack[0]['function']]))) { array_shift($stack); } $trace = $stack ? $stack[0] : []; $path = isset($trace['file']) ? $trace['file'] : ''; $line = isset($trace['line']) ? $trace['line'] : ''; $shortPath = ErrorConsole::shortFileName($path); $shortPath = str_segmentsLast($shortPath, '/'); $location = empty($line) ? $shortPath : ErrorConsole::errorLink($path, $line, 1, "{$shortPath}:{$line}", 'hint--rounded hint--left', 'data-hint'); if ($path != '') { $path = <<<HTML <div class="__debug-location">At {$location}</div> HTML; } $this->write($path); return $this; }
/** * @param \Error|\Exception $e * @param Expression $exp * @throws ComponentException */ private function evalError($e, Expression $exp) { throw new ComponentException($this, Debug::grid(['Expression' => Debug::RAW_TEXT . "<kbd>{$exp}</kbd>", 'Compiled' => sprintf('%s<code>%s</code>', Debug::RAW_TEXT, \PhpCode::highlight("{$exp->translated}")), 'Error' => sprintf('%s%s %s', Debug::RAW_TEXT, Debug::typeInfoOf($e), $e->getMessage()), 'At' => sprintf('%s%s, line <b>%s</b>', Debug::RAW_TEXT, ErrorConsole::errorLink($e->getFile(), $e->getLine()), $e->getLine())], 'Error while evaluating data-binding expression')); }
/** * Note: if the exception has a `getTitle()` method, that value is displayed as the popup's header, otherwise the * exception's class name will be shown instead. * * @param Exception|Error $exception * @param string $popupTitle * @param string $stackTrace */ static function renderPopup($exception, $popupTitle, $stackTrace) { self::renderStyles(); ?> <!DOCTYPE HTML><html> <head> <meta charset="UTF-8"> <title><?php echo $popupTitle; ?> </title> </head> <body id="__error"> <div id="__panel"> <div class="__title-bar"><?php echo $popupTitle; ?> </div> <div class="__panel-body"> <div id="__feedback">Please switch to PHPStorm/IDEA to view the code at the error location.</div> <img src="<?php echo self::getIcon(); ?> "> <div class="__message"> <?php $title = method_exists($exception, 'getTitle') ? $exception->getTitle() : self::friendlyClass(get_class($exception)); if ($title) { echo "<h3>{$title}</h3>"; } echo "<div>" . ucfirst(ErrorConsole::processMessage($exception->getMessage())) . "</div>"; if (!empty($exception->info)) { echo "<div class='__info'>{$exception->info}</div>"; } ?> </div> <div id="__error-location"> <?php $link = ErrorConsole::errorLink($exception->getFile(), $exception->getLine(), 1); if ($link) { echo "Thrown from {$link}, line <b>{$exception->getLine()}</b>"; } ?> <div class="__more"> <a id="__more" class=" __btn" href="javascript:void(document.getElementById('__panel').className='__show')" onclick="this.style.display='none';window.setTimeout(function(){document.body.scrollTop=document.getElementById('__error-location').offsetTop})"> Stack trace <span style="font-size:16px">▾</span></a> </div> </div> </div> <div id="__trace"> <?php echo $stackTrace; ?> </div> <iframe name="hidden" style="display:none"></iframe> </body><html> <?php }
/** * For use by renderers. * * @param string $msg * @return string */ public static function processMessage($msg) { $msg = preg_replace_callback('#<path>([^<]*)</path>#', function ($m) { return ErrorConsole::errorLink($m[1], 1, 1, basename($m[1])); }, $msg); return $msg; }