/** * @return int|null */ public function handle() { if (!$this->handleUnconditionally()) { // Check conditions for outputting HTML: // @todo: Make this more robust if (php_sapi_name() === 'cli') { // Help users who have been relying on an internal test value // fix their code to the proper method if (isset($_ENV['whoops-test'])) { throw new \Exception('Use handleUnconditionally instead of whoops-test' . ' environment variable'); } return Handler::DONE; } } $exception = func_get_arg(0); // @todo: Make this more dynamic $helper = new TemplateHelper(); $templateFile = $this->getResource("views/layout.html.php"); $cssFile = $this->getResource("css/whoops.base.css"); $zeptoFile = $this->getResource("js/zepto.min.js"); $jsFile = $this->getResource("js/whoops.base.js"); if ($this->customCss) { $customCssFile = $this->getResource($this->customCss); } $inspector = $this->getInspector(); $frames = $inspector->getFrames(); $code = $inspector->getException()->getCode(); if ($inspector->getException() instanceof \ErrorException) { // ErrorExceptions wrap the php-error types within the "severity" property $code = Misc::translateErrorCode($inspector->getException()->getSeverity()); } // List of variables that will be passed to the layout template. $vars = array("page_title" => $this->getPageTitle(), "stylesheet" => file_get_contents($cssFile), "zepto" => file_get_contents($zeptoFile), "javascript" => file_get_contents($jsFile), "header" => $this->getResource("views/header.html.php"), "frame_list" => $this->getResource("views/frame_list.html.php"), "frame_code" => $this->getResource("views/frame_code.html.php"), "env_details" => $this->getResource("views/env_details.html.php"), "title" => $this->getPageTitle(), "name" => explode("\\", $inspector->getExceptionName()), "message" => $inspector->getException()->getMessage(), "code" => $code, "plain_exception" => Formatter::formatExceptionPlain($inspector), "frames" => $frames, "has_frames" => !!count($frames), "handler" => $this, "handlers" => $this->getRun()->getHandlers(), "tables" => array("Server/Request Data" => $_SERVER, "GET Data" => $_GET, "POST Data" => $_POST, "Files" => $_FILES, "Cookies" => $_COOKIE, "Session" => isset($_SESSION) ? $_SESSION : array(), "Environment Variables" => $_ENV)); if (isset($customCssFile)) { $vars["stylesheet"] .= file_get_contents($customCssFile); } // Add extra entries list of data tables: // @todo: Consolidate addDataTable and addDataTableCallback $extraTables = array_map(function ($table) { return $table instanceof \Closure ? $table() : $table; }, $this->getDataTables()); $vars["tables"] = array_merge($extraTables, $vars["tables"]); $helper->setVariables($vars); ob_start(); $helper->render($templateFile); $content = ob_get_clean(); $pathMatches = (bool) preg_match('/phalcon-debugbar/', $exception->getFile()); if (is_object($this->di) && !$pathMatches) { try { $response = $this->di['response']->setContent($content); $response = $this->di['debugbar']->modifyResponse($response); $content = $response->getContent(); } catch (\Exception $e) { } } echo $content; return Handler::QUIT; }
/** * @return int|null */ public function handle() { $inspector = $this->getInspector(); $helper = new TemplateHelper(); $templateFile = $this->getResource("layout.html.php"); $cssFile = $this->getResource("error.css"); $code = $inspector->getException()->getCode(); if ($inspector->getException() instanceof \ErrorException) { $code = Misc::translateErrorCode($code); } $vars = array("stylesheet" => file_get_contents($cssFile), "code" => $code); $helper->setVariables($vars); $helper->render($templateFile); return Handler::QUIT; }
/** * @covers Whoops\Util\TemplateHelper::setVariables * @covers Whoops\Util\TemplateHelper::getVariables * @covers Whoops\Util\TemplateHelper::setVariable * @covers Whoops\Util\TemplateHelper::getVariable * @covers Whoops\Util\TemplateHelper::delVariable */ public function testTemplateVariables() { $this->helper->setVariables(array("name" => "Whoops", "type" => "library", "desc" => "php errors for cool kids")); $this->helper->setVariable("name", "Whoops!"); $this->assertEquals($this->helper->getVariable("name"), "Whoops!"); $this->helper->delVariable("type"); $this->assertEquals($this->helper->getVariables(), array("name" => "Whoops!", "desc" => "php errors for cool kids")); }
/** * @return int|null */ public function handleUserDebug($name2, $array) { if (!$this->handleUnconditionally()) { // Check conditions for outputting HTML: // @todo: Make this more robust if (php_sapi_name() === 'cli') { // Help users who have been relying on an internal test value // fix their code to the proper method if (isset($_ENV['whoops-test'])) { throw new \Exception('Use handleUnconditionally instead of whoops-test' . ' environment variable'); } return Handler::DONE; } } // @todo: Make this more dynamic $helper = new TemplateHelper(); $templateFile = $this->getResource("views/layout.html.php"); $cssFile = $this->getResource("css/whoops.base.css"); $zeptoFile = $this->getResource("js/zepto.min.js"); $jsFile = $this->getResource("js/whoops.base.js"); if ($this->customCss) { $customCssFile = $this->getResource($this->customCss); } //$inspector = $this->getInspector(); $frames = array(); $code = 1; // // List of variables that will be passed to the layout template. $vars = array("page_title" => $this->getPageTitle(), "stylesheet" => file_get_contents($cssFile), "zepto" => file_get_contents($zeptoFile), "javascript" => file_get_contents($jsFile), "header" => $this->getResource("views/header.html.php"), "frame_list" => $this->getResource("views/frame_list.html.php"), "frame_code" => $this->getResource("views/frame_code.html.php"), "env_details" => $this->getResource("views/env_details.html.php"), "title" => $this->getPageTitle(), "name" => array("Fiesta", "Debug"), "message" => $name2, "code" => $code, "plain_exception" => "DebugStatus thrown with message 'hhhh'\n\n\n\nStacktrace:\n\n#8 DebugStatus in C:\\wamp\\www\\Fiesta\\core\\Debug.php:10\n\n#7 Debug:stop in C:\\wamp\\www\\Fiesta\\app\\Routes.php:17\n\n#6 App:{closure} in <#unknown>:0\n\n#5 call_user_func_array in C:\\wamp\\www\\Fiesta\\core\\Access\\Routes_2.php:405\n\n#4 Routes:runRoute in C:\\wamp\\www\\Fiesta\\core\\Access\\Routes_2.php:303\n\n#3 Routes:exec in C:\\wamp\\www\\Fiesta\\core\\Access\\Routes_2.php:246\n\n#2 Routes:run in C:\\wamp\\www\\Fiesta\\core\\Ini.php:147\n\n#1 App:run in C:\\wamp\\www\\Fiesta\\bootstrap\\start.php:28\n\n#0 require in C:\\wamp\\www\\Fiesta\\public\\index.php:13", "frames" => $frames, "has_frames" => !!count($frames), "handler" => $this, "handlers" => array($this), "tables" => array("Selected parameters" => $array, "Server/Request Data" => $_SERVER, "GET Data" => $_GET, "POST Data" => $_POST, "Files" => $_FILES, "Cookies" => $_COOKIE, "Session" => isset($_SESSION) ? $_SESSION : array(), "Environment Variables" => $_ENV)); if (isset($customCssFile)) { $vars["stylesheet"] .= file_get_contents($customCssFile); } // Add extra entries list of data tables: // @todo: Consolidate addDataTable and addDataTableCallback $extraTables = array_map(function ($table) { return $table instanceof \Closure ? $table() : $table; }, $this->getDataTables()); $vars["tables"] = array_merge($extraTables, $vars["tables"]); $helper->setVariables($vars); $helper->render($templateFile); return Handler::QUIT; }
/** * @return int|null */ public function handle() { if (!$this->handleUnconditionally()) { // Check conditions for outputting HTML: // @todo: Make this more robust if (php_sapi_name() === 'cli') { // Help users who have been relying on an internal test value // fix their code to the proper method if (isset($_ENV['whoops-test'])) { throw new \Exception('Use handleUnconditionally instead of whoops-test' . ' environment variable'); } return Handler::DONE; } } // @todo: Make this more dynamic $helper = new TemplateHelper(); $cloner = new VarCloner(); // Only dump object internals if a custom caster exists. $cloner->addCasters(['*' => function ($obj, $a, $stub, $isNested, $filter = 0) { $class = $stub->class; $classes = [$class => $class] + class_parents($class) + class_implements($class); foreach ($classes as $class) { if (isset(AbstractCloner::$defaultCasters[$class])) { return $a; } } // Remove all internals return []; }]); $helper->setCloner($cloner); $templateFile = $this->getResource("views/layout.html.php"); $cssFile = $this->getResource("css/whoops.base.css"); $zeptoFile = $this->getResource("js/zepto.min.js"); $clipboard = $this->getResource("js/clipboard.min.js"); $jsFile = $this->getResource("js/whoops.base.js"); if ($this->customCss) { $customCssFile = $this->getResource($this->customCss); } $inspector = $this->getInspector(); $frames = $inspector->getFrames(); $code = $inspector->getException()->getCode(); if ($inspector->getException() instanceof \ErrorException) { // ErrorExceptions wrap the php-error types within the "severity" property $code = Misc::translateErrorCode($inspector->getException()->getSeverity()); } // List of variables that will be passed to the layout template. $vars = array("page_title" => $this->getPageTitle(), "stylesheet" => file_get_contents($cssFile), "zepto" => file_get_contents($zeptoFile), "clipboard" => file_get_contents($clipboard), "javascript" => file_get_contents($jsFile), "header" => $this->getResource("views/header.html.php"), "frame_list" => $this->getResource("views/frame_list.html.php"), "frame_code" => $this->getResource("views/frame_code.html.php"), "env_details" => $this->getResource("views/env_details.html.php"), "title" => $this->getPageTitle(), "name" => explode("\\", $inspector->getExceptionName()), "message" => $inspector->getException()->getMessage(), "code" => $code, "plain_exception" => Formatter::formatExceptionPlain($inspector), "frames" => $frames, "has_frames" => !!count($frames), "handler" => $this, "handlers" => $this->getRun()->getHandlers(), "tables" => array("GET Data" => $_GET, "POST Data" => $_POST, "Files" => $_FILES, "Cookies" => $_COOKIE, "Session" => isset($_SESSION) ? $_SESSION : array(), "Server/Request Data" => $_SERVER, "Environment Variables" => $_ENV)); if (isset($customCssFile)) { $vars["stylesheet"] .= file_get_contents($customCssFile); } // Add extra entries list of data tables: // @todo: Consolidate addDataTable and addDataTableCallback $extraTables = array_map(function ($table) { return $table instanceof \Closure ? $table() : $table; }, $this->getDataTables()); $vars["tables"] = array_merge($extraTables, $vars["tables"]); if (\Whoops\Util\Misc::canSendHeaders()) { header('Content-Type: text/html'); } $helper->setVariables($vars); $helper->render($templateFile); return Handler::QUIT; }
/** * @return int|null */ public function handle() { if (!$this->handleUnconditionally()) { // Check conditions for outputting HTML: // @todo: Make this more robust if (php_sapi_name() === 'cli') { // Help users who have been relying on an internal test value // fix their code to the proper method if (isset($_ENV['whoops-test'])) { throw new \Exception('Use handleUnconditionally instead of whoops-test' . ' environment variable'); } return Handler::DONE; } } // @todo: Make this more dynamic $helper = new TemplateHelper(); $templateFile = $this->getResource("views/layout.html.php"); $cssFile = $this->getResource("css/whoops.base.css"); $zeptoFile = $this->getResource("js/zepto.min.js"); $jsFile = $this->getResource("js/whoops.base.js"); if ($this->customCss) { $customCssFile = $this->getResource($this->customCss); } $inspector = $this->getInspector(); $frames = $inspector->getFrames(); // List of variables that will be passed to the layout template. $vars = array("page_title" => $this->getPageTitle(), "stylesheet" => file_get_contents($cssFile), "zepto" => file_get_contents($zeptoFile), "javascript" => file_get_contents($jsFile), "header" => $this->getResource("views/header.html.php"), "frame_list" => $this->getResource("views/frame_list.html.php"), "frame_code" => $this->getResource("views/frame_code.html.php"), "env_details" => $this->getResource("views/env_details.html.php"), "title" => $this->getPageTitle(), "name" => explode("\\", $inspector->getExceptionName()), "message" => $inspector->getException()->getMessage(), "frames" => $frames, "has_frames" => !!count($frames), "handler" => $this, "handlers" => $this->getRun()->getHandlers(), "tables" => array("Server/Request Data" => $_SERVER, "GET Data" => $_GET, "POST Data" => $_POST, "Files" => $_FILES, "Cookies" => $_COOKIE, "Session" => isset($_SESSION) ? $_SESSION : array(), "Environment Variables" => $_ENV)); if (isset($customCssFile)) { $vars["stylesheet"] .= file_get_contents($customCssFile); } // Add extra entries list of data tables: // @todo: Consolidate addDataTable and addDataTableCallback $extraTables = array_map(function ($table) { return $table instanceof \Closure ? $table() : $table; }, $this->getDataTables()); $vars["tables"] = array_merge($extraTables, $vars["tables"]); $helper->setVariables($vars); $helper->render($templateFile); return Handler::QUIT; }